https://leetcode-cn.com/problems/brick-wall/
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class Solution {
public int leastBricks(List<List<Integer>> wall) {
Map<Integer, Integer> pos2LeftAndCount = new HashMap<>();
for(List<Integer> w : wall){
int len = 0;
for(int i = 0; i < w.size() - 1; i++){
len += w.get(i);
pos2LeftAndCount.put(len, pos2LeftAndCount.getOrDefault(len, 0) + 1);
}
}
Integer num = 0;
for(Map.Entry entry : pos2LeftAndCount.entrySet()){
num = Math.max((Integer) entry.getValue(), num);
}
return wall.size() - num;
}
}