554. Brick Wall

class Solution {
public:
    int leastBricks(vector<vector<int>>& wall) {
        unordered_map<int,int> m;
        for (int i = 0; i < wall.size(); i++)
            for (int j = 0, t = 0; j < wall[i].size() - 1; j++) {
                t += wall[i][j];
                m[t]++;
            }
        int _max = 0;
        for (auto & p : m) {
            _max = max(_max, p.second);
        }
        return wall.size() - _max;
    }
};

猜你喜欢

转载自www.cnblogs.com/JTechRoad/p/9110427.html
今日推荐