class Solution {
public:
int leastBricks(vector<vector<int>>& wall) {
unordered_map<int, int> h;
for (auto& layer : wall) {
int s = 0;
for (int b : layer) {
s += b;
++h[s];
}
h[s] = 0;
}
int cnt = 0;
for (auto& [k, v] : h) {
cnt = max(cnt, v);
}
return wall.size() - cnt;
}
};