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; } };
原文地址:https://www.cnblogs.com/JTechRoad/p/9110427.html
时间: 2024-10-25 11:35:22