본문 바로가기
공부/2024 항해99코딩클럽

99클럽 코테 스터디 26일차 TIL + [LeetCode] 1476. Subrectangle Queries JAVA풀이/ 배열

by 푸딩코딩 2024. 6. 14.
728x90
반응형

 

 

 

 

 

 

1. 오늘의 학습 키워드


 

 

[LeetCode] 1476. Subrectangle Queries JAVA풀이/ 배열 

 

2. 오늘의 학습 문제 


문제


https://leetcode.com/problems/subrectangle-queries/

 

 

 

코드


class SubrectangleQueries {
    
    int[][] rectangle;

    public SubrectangleQueries(int[][] rectangle) {
        this.rectangle = rectangle;
    }
    
    public void updateSubrectangle(int row1, int col1, int row2, int col2, int newValue) {
        for(int i = row1; i <= row2; i++){
            for(int j = col1; j <= col2; j++){
                rectangle[i][j] = newValue;
            }
        }
    }
    
    public int getValue(int row, int col) {
        return rectangle[row][col];
    }
}

/**
 * Your SubrectangleQueries object will be instantiated and called as such:
 * SubrectangleQueries obj = new SubrectangleQueries(rectangle);
 * obj.updateSubrectangle(row1,col1,row2,col2,newValue);
 * int param_2 = obj.getValue(row,col);
 */

 

 

 

 

3. 오늘의 회고


 

  • 다시 풀어볼것!

 

 

 

728x90
반응형