Skip to content

Commit 9b67fb0

Browse files
committed
feat(leetcode): add No.3046
1 parent bb16935 commit 9b67fb0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

3046.Split-the-Array.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// https://leetcode.com/problems/split-the-array/description/
2+
// algorithms
3+
// Easy (56.7%)
4+
// Total Accepted: 35.5K
5+
// Total Submissions: 62.7K
6+
7+
8+
class Solution {
9+
10+
public boolean isPossibleToSplit(int[] nums) {
11+
Map<Integer, Integer> map = new HashMap<>();
12+
13+
for (int n : nums) {
14+
Integer curTime = map.get(n);
15+
if (curTime == null) {
16+
map.put(n, 1);
17+
} else if (curTime >= 2) {
18+
return false;
19+
} else {
20+
map.put(n, curTime + 1);
21+
}
22+
}
23+
24+
return true;
25+
}
26+
27+
}

0 commit comments

Comments
 (0)