标签:integer res bsp efault could ges pre blog min
The largest number could be n of walls.
class Solution { public int leastBricks(List<List<Integer>> wall) { if (wall.size() == 0) { return 0; } int result = wall.size(); Map<Integer, Integer> sumMap = new HashMap<>(); for (List<Integer> row : wall) { int sum = 0; for (int i = 0; i < row.size() - 1; i++) { sum += row.get(i); sumMap.put(sum, sumMap.getOrDefault(sum, 0) + 1); } } for (int value : sumMap.values()) { result = Math.min(wall.size() - value, result); } return result; } }
标签:integer res bsp efault could ges pre blog min
原文地址:http://www.cnblogs.com/shuashuashua/p/7468684.html