12345678910111213141516171819202122 |
- func leastBricks(wall [][]int) int {
- cnt := 0
- freq := make(map[int]int)
- for i := range wall {
- left := 0
- for _, w := range wall[i] {
- if left != 0 {
- freq[left]++
- cnt = maxInt(cnt, freq[left])
- }
- left += w
- }
- }
- return len(wall) - cnt
- }
- func maxInt(x, y int) int {
- if x < y {
- return y
- }
- return x
- }
|