row_vector and col_vector的建立 (Leetcode 807, Leetcode 531)

这两道题都需要建立row_vector and col_vector, 来统计每一行和每一列的信息。

Leetcode 807:
https://leetcode.com/problems/max-increase-to-keep-city-skyline/description/

class Solution {
public:
    int maxIncreaseKeepingSkyline(vector>& grid) {
        if(grid.empty() || grid[0].empty()){
            return 0;
        }
        
        int n = grid.size();
        vector row_record(n, 0), col_record(n, 0);
        for(int i=0; i

Leetcode 531:
https://leetcode.com/problems/lonely-pixel-i/description/

class Solution {
public:
    int findLonelyPixel(vector>& picture) {
        if(picture.empty() || picture[0].empty()){
            return 0;
        }
        
        int row = picture.size(), col = picture[0].size();
        vector row_record(row, 0);
        vector col_record(col, 0);
        
        for(int i=0; i

你可能感兴趣的:(row_vector and col_vector的建立 (Leetcode 807, Leetcode 531))