목록LeetCode (1)

https://leetcode.com/problems/spiral-matrix-ii/description/?envType=problem-list-v2&envId=simulation 제한된 2차원 배열 공간 안에서 뱅글뱅글 도는 규칙이 있을 경우, 벽이 있다고 생각하면 쉽다.row의 start와 end, column의 start와 end를 기준으로 벽이 있다고 생각하고, 한 줄 (가로든, 세로든) 을 채울때 마다 벽이 한칸씩 조여지는 느낌으로 생각하면 까먹지 않을 것 같다. class Solution { public int[][] generateMatrix(int n) { int[][] res = new int[n][n]; int counter = 1; int c..
LeetCode
2025. 1. 19. 21:35