[Leetcode - Medium] Set Matrix Zeroes #40
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.
문제
Constraints
m == matrix.lengthn == matrix[0].length1 <= m, n <= 200-231 <= matrix[i][j] <= 231 - 1Edge Case
풀이
row,col을 각각 따로zeroRows,zeroColsset에 저장한다.zeroRows집합을 순회하면서zeroRow에 해당하는 모든col에 대해 0으로 수정한다.zeroCols집합을 순회하면서zeroCol에 해당하는 모든row에 대해 0으로 수정한다.어려웠던 점
DFS로 문제 풀이 방법을 정하고 문제 풀이를 시도해보니 코드가 어느정도 완성된 상태에서 반례 케이스에 대한 대응이 어려웠다.
알게된 점