[Leetcode - Medium] Set Matrix Zeroes #47
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
문제
m, n은 matrix의 행, 열의 길이
Constraints
Edge Case
x
풀이
matrix의 행열을 for을 두번해서 돈다
만약, 값이 0인 행열 인덱스를 발견하면 상하좌우 4번을 for로 돌며 그 내부에서
한번도 안 갔고, 인덱스가 유효한지 체킹하고 맞다면 visited에 현재 위치값을 저장하고, arr에 현재 위치 정보를 배열로 저장한다
=> 이미 같은 방향으로 같은 지점을 들렸다면 bfs를 돌면서 더 0으로 바꾸는 행위를 할 필요 없기에 해당 조건을 체킹
while을 arr가 0이 될 때까지 돌며,
3의 과정이 끝난 이후, 변경된 matrix를 return 한다
어려웠던 점
처음에 visited 저장 안 하다가 한번 꼬여서 시간이 더 걸렸던 것 같습니다
알게된 점
x