easy java solution.

  • 0
    public int leastBricks(List<List<Integer>> wall) {
            HashMap<Integer,Integer> mapper = new HashMap<>();
            int max = 0;
            for(List<Integer> row: wall){
                int val=0;
                for(int i =0;i<row.size()-1;i++){
                    max = Math.max(max,mapper.get(val));
            return wall.size()-max;

    BTW, there must be some follow ups of this problem. But I can't think more of it.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.