https://leetcode.com/problems/subrectangle-queries/
#include <vector>
#include <algorithm>
using namespace std;
class SubrectangleQueries {
public:
vector<vector<int>> rec;
SubrectangleQueries(vector<vector<int>>& rectangle) {
rec = rectangle;
}
void updateSubrectangle(int row1, int col1, int row2, int col2, int newValue) {
for (int i = row1; i <= row2; i++) {
fill(rec[i].begin()+col1, rec[i].begin()+col2+1, newValue);
}
}
int getValue(int row, int col) {
return rec[row][col];
}
};
'Problem-Solving > LeetCode' 카테고리의 다른 글
[Leetcode] 419. Battleships in a Board (0) | 2020.07.28 |
---|---|
[Leetcode] 1111. Maximum Nesting Depth of Two Valid Parentheses Strings (C++) (0) | 2020.07.14 |
[Leetcode] 1387. Sort Integers by The Power Value (C++) (0) | 2020.07.07 |
[Leetcode] 1448. Count Good Nodes in Binary Tree (C++) (0) | 2020.06.28 |