Algorithm
-
[Leetcode] 343. Integer Break 문제풀이Algorithm/문제풀이 2021. 10. 2. 13:43
https://leetcode.com/problems/integer-break/ Integer Break - 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이 주어질 때 숫자 n을 쪼개서 더할 수 있는 정수 배열을 만들고, 그 정수 배열의 모든 곱이 가장 큰 값 구하기 Example 1: Input: n = 2 Output: 1 Explanation: 2 = 1 + 1 (정수 배열을 1,1로 쪼갠뒤) , 1 × 1 = 1. (해당 배열을 곱함)..
-
[Leetcode] 1143. Longest Common Subsequence 문제풀이Algorithm/문제풀이 2021. 10. 1. 17:26
https://leetcode.com/problems/longest-common-subsequence/ Longest Common Subsequence - 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 문제 내용 2개의 문자열에서 공통된 부분 문자열을 구하는 문제 Example 1: Input: text1 = "abcde", text2 = "ace" Output: 3 Explanation: The longest common subsequence is "ace" ..
-
[Leetcode] 300. Longest Increasing Subsequence 문제풀이Algorithm/문제풀이 2021. 10. 1. 14:35
https://leetcode.com/problems/longest-increasing-subsequence/ Longest Increasing Subsequence - 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 문제 내용 배열에서 증가하는 수열중에 길이가 가장 큰 수열 찾기 문제 Example 1: Input: nums = [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequ..
-
[Leetcode] 62. Unique Paths 문제풀이Algorithm/문제풀이 2021. 9. 29. 21:31
https://leetcode.com/problems/unique-paths/ Unique Paths - 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 문제 내용 로봇이 오른쪽 또는 아래로 한칸씩 이동하는데, 출발점부터 도착점까지 경로의 개수를 구하는 문제 Example 1: Input: m = 3, n = 7 Output: 28 문제 풀이 1칸을 이동할 때 어디서 오는지 생각하면 금방 DP식을 구할 수 있다. Dist[y][x] = Dist[y-1][x]+ D..
-
[Leetcode] 45. Jump Game II 문제 풀이Algorithm/문제풀이 2021. 9. 29. 21:10
https://leetcode.com/problems/jump-game-ii/ Jump Game 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 문제 내용 몇 번만에 점프해서 끝지점 까지 오는지 최소 값을 구하는 문제 Example 1: Input: nums = [2,3,1,1,4] Output: 2 Explanation: The minimum number of jumps to reach the last index is 2. Jump 1 step from..
-
[Leetcode] 55. Jump Game 문제풀이Algorithm/문제풀이 2021. 9. 29. 20:24
https://leetcode.com/problems/jump-game/ Jump Game - 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 문제 내용 점프 가능한 칸이 주어질 때, 끝점에 도착할 수 있는지 출력 Example 1: Input: nums = [2,3,1,1,4] Output: true Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index. 문제 풀이 DP를 이용해서 ..
-
[Leetcode] 213. House Robber II 문제 풀이Algorithm/문제풀이 2021. 9. 29. 19:50
https://leetcode.com/problems/house-robber-ii/ House Robber 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 문제 내용 집에 있는 물건을 훔치는 데 가장 많이 훔치는 값을 구하는 문제 옆집을 연속해서 훔칠수도 없고, 끝도 연결되어 있는 원형 마을 Example 1: Input: nums = [2,3,2] Output: 3 Explanation: You cannot rob house 1 (money = 2) a..
-
[Leetcode] 922. Sort Array By Parity II 문제 풀이Algorithm/문제풀이 2021. 9. 28. 23:39
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 문제 내용 i가 홀수이면 num[i] 도 홀수로, i가 짝수이면 num[i] 도 짝수가 되도록 정렬하는 문제 Example 1: Input: nums = [4,2,5,7] Output: [4,5,2,7] Explanation: [4,7,2,5], [2,5,4,7], [2,7..