Skip to content

Commit 252eda7

Browse files
authored
Create Split the Array.java
1 parent 4aef2f9 commit 252eda7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Easy/Split the Array.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public boolean isPossibleToSplit(int[] nums) {
3+
return Arrays.stream(nums)
4+
.boxed()
5+
.collect(Collectors.groupingBy(Function.identity(), HashMap::new, Collectors.counting()))
6+
.values()
7+
.stream()
8+
.allMatch(v -> v <= 2);
9+
}
10+
}

0 commit comments

Comments
 (0)