C++ unordered_map


  • 0
    T
    class Solution {
    public:
        int leastBricks(vector<vector<int>>& wall) {
            unordered_map<int, int> edges;
            int width = 0;
            for (auto &w:wall) {
                int indx = 0;
                for (int i:w) {
                    ++edges[indx+=i];
                }
                if (!width) width = indx;
            }
            edges.erase(width);
            int throughs = 0;
            for (auto &p:edges) {
                rst = max(throughs, p.second);
            }
            return wall.size() - size_t(throughs);
        }
    };

Log in to reply
 

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