Skip to content

Commit f9b9b6c

Browse files
authored
Merge branch 'master' into sambabib-js-solutions
2 parents b7dc87f + efa91d4 commit f9b9b6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1876
-601
lines changed

cpp/_916.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
class Solution {
2+
public:
3+
vector<string> wordSubsets(vector<string>& words1, vector<string>& words2) {
4+
int maxCharFreq[26] = {0};
5+
int tempCharFreq[26];
6+
for (const auto& word : words2) {
7+
memset(tempCharFreq, 0, sizeof tempCharFreq);
8+
for (char ch : word) {
9+
tempCharFreq[ch - 'a']++;
10+
}
11+
for (int i = 0; i < 26; ++i) {
12+
maxCharFreq[i] = max(maxCharFreq[i], tempCharFreq[i]);
13+
}
14+
}
15+
vector<string> universalWords;
16+
for (const auto& word : words1) {
17+
memset(tempCharFreq, 0, sizeof tempCharFreq);
18+
for (char ch : word) {
19+
tempCharFreq[ch - 'a']++;
20+
}
21+
bool isUniversal = true;
22+
for (int i = 0; i < 26; ++i) {
23+
if (maxCharFreq[i] > tempCharFreq[i]) {
24+
isUniversal = false;
25+
break;
26+
}
27+
}
28+
if (isUniversal) {
29+
universalWords.emplace_back(word);
30+
}
31+
}
32+
return universalWords;
33+
}
34+
};

paginated_contents/algorithms/2nd_thousand/README.md

Lines changed: 275 additions & 274 deletions
Large diffs are not rendered by default.

paginated_contents/algorithms/3rd_thousand/README.md

Lines changed: 284 additions & 283 deletions
Large diffs are not rendered by default.

paginated_contents/algorithms/4th_thousand/README.md

Lines changed: 72 additions & 41 deletions
Large diffs are not rendered by default.

paginated_contents/database/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| 3059 |[Find All Unique Email Domains](https://leetcode.com/problems/find-all-unique-email-domains/)| [Solution](https://github.com/fishercoder1534/Leetcode/blob/master/database/_3159.sql) || Easy |
77
| 3051 |[Find Candidates for Data Scientist Position](https://leetcode.com/problems/find-candidates-for-data-scientist-position/)| [Solution](https://github.com/fishercoder1534/Leetcode/blob/master/database/_3051.sql) || Easy |
88
| 2990 |[Loan Types](https://leetcode.com/problems/loan-types/)| [Solution](https://github.com/fishercoder1534/Leetcode/blob/master/database/_2990.sql) || Easy |
9+
| 2879 |[Display the First Three Rows](https://leetcode.com/problems/display-the-first-three-rows/)| [Python3](https://github.com/fishercoder1534/Leetcode/blob/master/python3/2879.py) || Easy |
910
| 2205 |[The Number of Users That Are Eligible for Discount](https://leetcode.com/problems/the-number-of-users-that-are-eligible-for-discount/)| [Solution](https://github.com/fishercoder1534/Leetcode/blob/master/database/_2205.sql) || Easy |
1011
| 2082 |[The Number of Rich Customers](https://leetcode.com/problems/the-number-of-rich-customers/)| [Solution](https://github.com/fishercoder1534/Leetcode/blob/master/database/_2082.sql) || Easy |
1112
| 2072 |[The Winner University](https://leetcode.com/problems/the-winner-university/)| [Solution](https://github.com/fishercoder1534/Leetcode/blob/master/database/_2072.sql) || Easy |

python3/2879.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import pandas as pd
2+
3+
def selectFirstRows(employees: pd.DataFrame) -> pd.DataFrame:
4+
return employees.head(3)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
public class _3270 {
4+
public static class Solution1 {
5+
public int generateKey(int num1, int num2, int num3) {
6+
String[] padded = new String[3];
7+
padded[0] = String.format("%04d", num1);
8+
padded[1] = String.format("%04d", num2);
9+
padded[2] = String.format("%04d", num3);
10+
StringBuilder sb = new StringBuilder();
11+
for (int i = 0; i < padded[0].length(); i++) {
12+
sb.append(
13+
Math.min(
14+
Character.getNumericValue(padded[0].charAt(i)),
15+
Math.min(
16+
Character.getNumericValue(padded[1].charAt(i)),
17+
Character.getNumericValue(padded[2].charAt(i)))));
18+
}
19+
return Integer.parseInt(sb.toString());
20+
}
21+
}
22+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class _3274 {
7+
public static class Solution1 {
8+
public boolean checkTwoChessboards(String coordinate1, String coordinate2) {
9+
return isBlack(coordinate2) == isBlack(coordinate1);
10+
}
11+
12+
private boolean isBlack(String coordinate) {
13+
Set<Character> blackColsWithOddRows = new HashSet<>();
14+
blackColsWithOddRows.add('a');
15+
blackColsWithOddRows.add('c');
16+
blackColsWithOddRows.add('e');
17+
blackColsWithOddRows.add('g');
18+
if (blackColsWithOddRows.contains(coordinate.charAt(0))) {
19+
return Character.getNumericValue(coordinate.charAt(1)) % 2 == 1;
20+
} else {
21+
return Character.getNumericValue(coordinate.charAt(1)) % 2 == 0;
22+
}
23+
}
24+
}
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
public class _3280 {
4+
public static class Solution1 {
5+
public String convertDateToBinary(String date) {
6+
String[] parts = date.split("-");
7+
StringBuilder sb = new StringBuilder();
8+
for (String part : parts) {
9+
sb.append(Integer.toBinaryString(Integer.parseInt(part)));
10+
sb.append("-");
11+
}
12+
sb.setLength(sb.length() - 1);
13+
return sb.toString();
14+
}
15+
}
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class _3285 {
7+
public static class Solution1 {
8+
public List<Integer> stableMountains(int[] height, int threshold) {
9+
List<Integer> ans = new ArrayList<>();
10+
for (int i = 1; i < height.length; i++) {
11+
if (height[i - 1] > threshold) {
12+
ans.add(i);
13+
}
14+
}
15+
return ans;
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)