5주차 7주차 알고리즘 풀이 - 이준희 - #33
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
[5주차]
문제: BOJ1780 - 종이의 개수
🐣풀이 방법
시간복잡도: O(n*n)
재귀를 활용한 문제, 문제에서 조건을 만족하지못하면 9방향으로 나누어주어야하기때문에, 만약 숫자가 동일하지않는 경우, 길이를 새로 계산해주고, 9방향으로 나누어 재귀하는 방식으로 풀이하였다.
문제: BOJ2630 - 색종이 만들기
🐣풀이 방법
시간복잡도: O(n*n)
종이의 개수가 9방향이었다면 4방향이된 쉬워진 버젼, 풀이방식은 종이의 개수와 동일하고 재귀를 4방향으로 진행한다는 차이이다.
문제: BOJ1992 - 쿼드트리
🐣풀이 방법
시간복잡도: O(n*n)
색종이 만들기와 동일하지만, 재귀 시작전과 후에 ( ) 괄호를 sb에 적재하여 재귀단계를 표시해주면되는 문제이다.
문제: BOJ15650 - N과 M(2) - (8)
주어진 숫자까지의 반복문을 통해, depth가 n이되면 탈출하고 아니면 dfs를 통해 풀이한 문제이다.
[7주차]
문제: BOJ5648 - 역원소 정렬
🐣풀이 방법
시간복잡도: O(n*n)
반복문을 많이 중첩하여, 좋은 풀이법은 아니었던것같다.
문자열을 뒤집어 정렬하기 위하여 charAt을 활용하여 풀이하였다.
StringBuilder내의
reverse()메서드를 활용하여 깔끔하게 리팩토링해보아야겠다.문제: BOJ1181 - 단어 정렬
🐣풀이 방법
시간복잡도: O(n*n)
길이가 짧은것부터, 중복없이 사전순으로 정렬 우선순위를 재정의해주기위해 클래스를 선언하여 풀이하였다.
중복제거를 위해, 반복문을 사용하였는데, Set과 Stream을 적절히 활용해서 풀이하였으면 더 깔끔했을것같다.
문제: BOJ2910 - 빈도 정렬
🐣풀이 방법
시간복잡도: O(n*n)
등장하는 횟수가 같다면, 먼저 나온 것이 앞에 있어야 하므로 순서를 보장해주는 linkedHashMap을 이용하여 풀이하였다.
마찬가지로 class를 정의하여 정렬을 재정의하여 풀이하였다.
문제: BOJ10815 - 숫자 카드
🐣풀이 방법
시간복잡도 : O(n)
단순히 처음 입력값에 대한 존재 유무만 체크하면되는 문제였기에 컬렉션의 Set 사용하여 풀이
문제: BOJ1822 - 차집합
🐣풀이 방법
시간복잡도 : O(n)
정렬과 중복체크를 위해 Treeset을 사용하여 풀이하였다.