Skip to content

Commit 3616f5a

Browse files
authored
Create Solution.java
1 parent e9ca37a commit 3616f5a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int leastBricks(List<List<Integer>> wall) {
3+
Map<Integer, Integer> map = new HashMap<>();
4+
for (List<Integer> list : wall) {
5+
int s = 0;
6+
for (int i = 0; i < list.size() - 1; ++i) {
7+
s += list.get(i);
8+
map.put(s, map.getOrDefault(s, 0) + 1);
9+
}
10+
}
11+
int max = map.values().stream().max(Integer::compare).orElse(0);
12+
return wall.size() - max;
13+
}
14+
}

0 commit comments

Comments
 (0)