https://github.com/kingmin2/LeetCode/tree/main/54-spiral-matrix
GitHub - kingmin2/LeetCode
Contribute to kingmin2/LeetCode development by creating an account on GitHub.
github.com
< 문제 이해하기 >
- 2차원 배열 matrix가 주어지고 시계방향으로 회전하면서 arrayList<Integer>에 담아 리턴.
<해설>
1. 왼쪽, 오른쪽, 상, 하 값을 선언한다.
2. arrayList<Integer>에 담긴 사이즈가 count 보다 작을때까지 while문을 돌린다.
3. 동->남->서->북 순으로 담는다.
'코딩테스트 > LeetCode' 카테고리의 다른 글
[LeetCode]153. Find Minimum in Rotated Sorted Array (0) | 2022.11.07 |
---|---|
[LeetCode]54. Spiral Matrix (0) | 2022.11.04 |
[LeetCode]202. Happy Number (0) | 2022.11.03 |
[LeetCode]74. Search a 2D Matrix (0) | 2022.11.03 |
[LeetCode]34. Find First and Last Position of Element in Sorted Array (0) | 2022.11.02 |