HYEWON CHOI : PROGRAMMERS Lv2 행렬 테두리 회전하기 #367
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.
Programmers - 행렬 테두리 회전하기
-행렬 테두리 회전하기 문제 바로가기
풀이
먼저 rows X columns 크기의 배열을 만들어주어 순서대로 점점 1씩 커지는 숫자를 넣어주었습니다.
그리고 배열의 x1,y1에 위치한 값은 tmp에 넣어주고 각각 회전을 시켜주었습니다.
회전을 하면서 Math.min을 통해 회전하는 수 중 최솟값을 구해주었습니다.
그리고 tmp값은 x1,y1+1 위치에 넣어주어 회전을 완료하였고 순서대로 최솟값을 구해주어 답을 구하였습니다.
소스코드
결과