C++ short and easy solution


  • 0
    M
        int leastBricks(vector<vector<int>>& wall) {
            unordered_map<int, int> gap;
            int res=0;
            for(int i=0;i<wall.size();i++) {
                int temp=0;
                for(int j=0;j<wall[i].size()-1;j++) {
                    temp+=wall[i][j];
                    gap[temp]++;
                    if(gap[temp]>res) res=gap[temp];
                }
            }
            return wall.size()-res;
        }

Log in to reply
 

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