분류 전체보기
-
[BOJ] 20164. 홀수 홀릭 호석알고리즘 문제 풀이 2021. 10. 6. 13:08
문제 출처: https://www.acmicpc.net/problem/20164 20164번: 홀수 홀릭 호석 호석이는 짝수랑 홀수 중에서 이니셜이 같은 홀수를 더 좋아한다. 운전을 하던 호석이는 앞차의 번호판이 홀수로 가득할 때 사랑스러움을 느낄 정도이다. 전화번호도 홀수만 있고 싶다. 그렇게 www.acmicpc.net 문제 가지고 있는 수 N을 일련의 연산을 거치면서, 등장하는 숫자들에서 홀수를 최대한 많이 보려고 한다. 하나의 수가 주어졌을 때, 다음과 같은 연산을 수행한다. 수의 각 자리 숫자 중에서 홀수의 개수를 종이에 적는다. 수가 한 자리이면 더 이상 아무것도 하지 못하고 종료한다. 수가 두 자리이면 2개로 나눠서 합을 구하여 새로운 수로 생각한다. 수가 세 자리 이상이면 임의의 위치에서 ..
-
[LeetCode] 70. Climbing Stairs알고리즘 문제 풀이 2021. 10. 5. 10:22
문제 출처: https://leetcode.com/problems/climbing-stairs/ Climbing Stairs - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 계단을 오르고 있는데, 꼭대기까지 n개의 계단이 있습니다. 한 번에 1개 또는 2개의 계단을 오를 수 있습니다. 꼭대기까지 도착하는데 몇 개의 방법이 존재하는가? 예제 Input: n = 2 Output: 2 Explanation: There are two ways to climb t..
-
[LeetCode] 463. Island Perimeter알고리즘 문제 풀이 2021. 10. 4. 13:58
문제 출처: https://leetcode.com/problems/island-perimeter/ Island Perimeter - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 지도가 $row \times col$ 크기의 $grid$로 표현되어 주어진다. $grid[i][j] = 1$은 땅을 의미하고 $grid[i][j] = 0$은 물을 의미한다. 격자 칸은 상하좌우로 연결되어 있다(대각 연결은 없음). $grid$는 사방이 물로 둘러싸여 있으며, 정확히..
-
[LeetCode] 698. Partition to K Equal Sum Subsets알고리즘 문제 풀이 2021. 10. 1. 14:26
문제 출처: https://leetcode.com/problems/partition-to-k-equal-sum-subsets/ Partition to K Equal Sum Subsets - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 정수 배열 nums와 정수 k가 주어지면, 합이 동일한 k개의 비어있지 않는 부분집합을 만들 수 있다면 true를 반환하라. 예제 Input: nums = [4,3,2,3,5,2,1], k = 4 Output: true Ex..
-
[LeetCode] 725. Split Linked List in Parts알고리즘 문제 풀이 2021. 9. 30. 14:03
문제 출처: https://leetcode.com/problems/split-linked-list-in-parts/ Split Linked List in Parts - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 단일 연결 리스트의 head와 정수 k가 주어지면, 연속으로 연결된 k개의 연결 리스트로 분리하라. 각 부분의 길이는 가능한 한 동일해야 한다: 어떤 두 부분도 크기가 1보다 크게 차이 나서는 안된다. 이러한 조건이 일부 부분에 null 값을 이..
-
[LeetCode] 922. Sort Array By Parity II알고리즘 문제 풀이 2021. 9. 29. 11:40
문제 출처: https://leetcode.com/problems/sort-array-by-parity-ii/ Sort Array By Parity II - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 홀수와 짝수 정수가 절반씩 구성된 정수 배열 nums가 주어진다. i가 홀수일 때 nums[i]가 홀수가 되고, i가 짝수일 때 nums[i]가 짝수가 되도록 정렬하라. 이 조건을 만족하는 배열 중 하나를 반환하라. 예제 Input: nums = [4,2,..
-
[LeetCode] 929. Unique Email Addresses알고리즘 문제 풀이 2021. 9. 28. 10:26
문제 출처: https://leetcode.com/problems/unique-email-addresses/ Unique Email Addresses - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 모든 유효한 이메일은 '@'기호로 구분되는 로컬 이름과 도메인 이름으로 구성된다. 추가적으로 이메일은 소문자와 더불어 한 개 이상의 '.' 또는 '+'를 포함할 수 있다. 예를 들어, "alice@leetcode.com"에서 "alice"는 로컬 이름이고 "l..
-
[LeetCode] 332. Reconstruct Itinerary알고리즘 문제 풀이 2021. 9. 27. 17:30
문제 출처: https://leetcode.com/problems/reconstruct-itinerary/ Reconstruct Itinerary - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 항공권 리스트 $tickets$가 주어진다. $tickets[i] = [from_i, to_i]$는 출발지와 도착지를 표현하고 있다. 여행 일정을 세우고, 반환하라. 모든 tickets는 "JFK"에서 출발하는 사람의 것이기 때문에, 여행 일정은 "JFK"에서 시..