Week8 서영탁 SWEA 5658 보물상자비밀번호 풀이 #139
Open
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.
풀이
보물상자의 뚜껑을 시계방향으로 돌릴 때 각 변의 숫자를 비밀번호로 추출하는 문제이었습니다.
그럼 n/4번 이상으로 돌릴 때 비밀번호의 중복이 발생하기 때문에 n/4번만 회전시켜 비밀번호를 추출하여 set에 저장하였습니다.
모든 비밀번호를 추출한 후, set을 list에 저장하고 정렬을 했습니다.
오름차순으로 정렬했기 때문에, 뒤에서부터 k번째 비밀번호를 가져와 String을 16진수로 변경하여 출력했습니다.
리뷰 요청 사항
궁금한 점이 있다면 리뷰남겨주세요.
느낀점
TreeSet을 사용해서도 풀 수 있습니다. (정렬된 set)