Leetcode 554. 砖墙
文章目录
- 题目
- 代码(9.25 首刷自解)
题目
Leetcode 554. 砖墙
代码(9.25 首刷自解)
class Solution {
public:int leastBricks(vector<vector<int>>& wall) {unordered_map<int, int> mp;int count = 0;for(auto& sub : wall) {int pre = 0;for(int i = 0; i < sub.size()-1; i++) {pre += sub[i];mp[pre]++;count = max(count, mp[pre]);}}return wall.size()-count;}
};