@@ -0,0 +1,1293 @@
+package org.song.java8;%0A%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Apublic class BrickWall %7B%0A%0A    private static class Count %7B%0A        private int count = 0;%0A%0A        public void increase() %7B%0A            count ++;%0A        %7D%0A%0A        public int count() %7B%0A            return count;%0A        %7D%0A    %7D%0A%0A    public int leastBricks(int%5B%5D%5B%5D wall) %7B%0A        if (wall == null %7C%7C wall.length == 0) %7B%0A            return 0;%0A        %7D%0A%0A        Map%3CInteger, Count%3E map = new HashMap%3C%3E();%0A%0A        for (int%5B%5D row : wall) %7B%0A            int keyByLength = 0;%0A            int index = -1;%0A            for (Integer i : row) %7B%0A                keyByLength += i;%0A                if (++ index %3C row.length - 1) %7B%0A                    map.computeIfAbsent(keyByLength, k -%3E new Count()).increase();%0A                %7D%0A            %7D%0A        %7D%0A%0A        int height = wall.length;%0A        int min = height;%0A        for (Count count: map.values()) %7B%0A            min = Math.min(min, height - count.count());%0A        %7D%0A        return min;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        int%5B%5D%5B%5D wall = new int%5B%5D%5B%5D %7B%7B1,2,2,1%7D,%7B3,1,2%7D,%7B1,3,2%7D,%7B2,4%7D,%7B3,1,2%7D,%7B1,3,1,1%7D%7D;%0A%0A        BrickWall brickWall = new BrickWall();%0A        System.out.print(%22least: %22 + brickWall.leastBricks(wall));%0A    %7D%0A%7D%0A

add BrickWall