Algorithm
-
[Leetcode] 929. Unique Email Addresses 문제 풀이Algorithm/문제풀이 2021. 9. 27. 20:27
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 문제 내용 이메일에 문자가 섞여있는데 문자를 규칙에 따라 제거했을 때 남은 이메일은 몇개인지 찾는 문제 Example 1: Input: emails = ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","..
-
[Leetcode] Shortest Path in a Grid with Obstacles Elimination 문제 풀이Algorithm/문제풀이 2021. 9. 25. 17:23
https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination/ Shortest Path in a Grid with Obstacles Elimination - 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 문제 내용 장애물을 피해서 최단거리를 찾는 문제인데 k번 만큼 장애물을 제거하고 갈 수 있다. 그렇게 했을 때 최단거리를 구하는 문제 Example 1: Input: grid =..
-
[Leetcode] 1137. N-th Tribonacci Number 문제 풀이Algorithm/문제풀이 2021. 9. 24. 16:38
https://leetcode.com/problems/n-th-tribonacci-number/ N-th Tribonacci Number - 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 문제 내용 피보나치 수열처럼 3개를 더한 값을 다음으로 쓰는 수열에서 N 번째 수 구하기 Example 1: Input: n = 4 Output: 4 Explanation: T_3 = 0 + 1 + 1 = 2 T_4 = 1 + 1 + 2 = 4 문제 풀이 단순히 반복문을 돌리면..
-
[Leetcode] 572. Subtree of Another Tree 문제 풀이Algorithm/문제풀이 2021. 9. 22. 22:33
https://leetcode.com/problems/subtree-of-another-tree/ Subtree of Another Tree - 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 문제 내용 tree에서 subtree가 있는지 검사하는 문제 Example 1: Input: root = [3,4,5,1,2], subRoot = [4,1,2] Output: true 문제 풀이 tree가 일치하는 지 매칭하기 위해 dfs탐색으로 풀었다. 먼저 subroot..
-
[Leetcode] 117. Populating Next Right Pointers in Each Node II 문제 풀이Algorithm/문제풀이 2021. 9. 22. 16:12
https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/ Populating Next Right Pointers in Each Node 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 문제 내용 이진 트리에 next 라는 같은 레벨에서 옆을 가리키는 포인트를 추가하는 문제 Example 1: Input: root = [1,2,3,4,5,null,7] Output: [1,#,..
-
[Leetcode] 547. Number of Provinces 문제 풀이Algorithm/문제풀이 2021. 9. 22. 12:53
https://leetcode.com/problems/number-of-provinces/ Number of Provinces - 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 문제 내용 서로 연결된 노드를 하나의 province라고 하고, province의 갯수를 구하는 문제 Example 1: Input: isConnected = [[1,1,0],[1,1,0],[0,0,1]] Output: 2 문제 풀이 dfs를 이용해서 서로 연결된 노드를 방문 할 수 있다..
-
[Leetcode] 200. Number of Islands 문제 풀이Algorithm/문제풀이 2021. 9. 22. 12:34
https://leetcode.com/problems/number-of-islands/ Number of Islands - 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 문제 내용 grid 가 주어지는데, '1'은 땅이고 '0'은 물로 구성되어 있다. 물로 둘러 쌓인 섬의 개수를 구하는 문제 Example 1: Input: grid = [ ["1","1","1","1","0"], ["1","1","0","1","0"], ["1","1","0","0","0"], ..
-
[Leetcode] 209. Minimum Size Subarray Sum 문제 풀이Algorithm/문제풀이 2021. 9. 22. 12:11
https://leetcode.com/problems/minimum-size-subarray-sum/ Minimum Size Subarray Sum - 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 문제 내용 연속된 subarray 중에 값을 다 합친 값이 target 보다 크거나 같은 경우, 그 길이가 최소인 길이를 구하는 문제 Example 1: Input: target = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: ..