전체 글
-
[Leetcode] 88. Merge Sorted Array 문제풀이Algorithm/문제풀이 2021. 10. 8. 16:31
https://leetcode.com/problems/merge-sorted-array/ Merge Sorted Array - 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개의 배열을 merge sort로 합치기 Example 1: Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3 Output: [1,2,2,3,5,6] Explanation: The arrays we are merging a..
-
[Leetcode] 1. Two Sum 문제 풀이Algorithm/문제풀이 2021. 10. 8. 15:08
https://leetcode.com/problems/two-sum/ Two 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 문제 내용 2개를 더해서 target 되는 index를 구하는 문제 Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1]. 문제 풀이 일반적으로 하면 O(n^2) 만큼 걸..
-
[Leetcode] 208. Implement Trie (Prefix Tree) 문제 풀이Algorithm/문제풀이 2021. 10. 8. 10:14
https://leetcode.com/problems/implement-trie-prefix-tree/ Implement Trie (Prefix 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 문제 내용 Trie 구현 Example 1: Input ["Trie", "insert", "search", "search", "startsWith", "insert", "search"] [[], ["apple"], ["apple"], ["app"], ["app..
-
[Leetcode] 79. Word Search 문제 풀이Algorithm/문제풀이 2021. 10. 7. 11:34
https://leetcode.com/problems/word-search/ Word Search - 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 문제 내용 문자로 구성된 board가 있는데 찾고자 하는 단어가 board에서 찾을 수 있는 지 검사하는 문제 Example 1: Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED" Output: true 문제 ..
-
[Leetcode] 442. Find All Duplicates in an Array 문제풀이Algorithm/문제풀이 2021. 10. 6. 22:57
https://leetcode.com/problems/find-all-duplicates-in-an-array/ Find All Duplicates in an Array - 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 문제 내용 배열 중에 같은 수 찾기 문제 요소는 1개 또는 2개로 이루어져있다. Example 1: Input: nums = [4,3,2,7,8,2,3,1] Output: [2,3] 문제 풀이 시간복잡도 O(n), 공간복잡도 O(1) 만에 풀 수..
-
[Leetcode] 217. Contains Duplicate 문제풀이Algorithm/문제풀이 2021. 10. 5. 13:21
https://leetcode.com/problems/contains-duplicate/ Contains Duplicate - 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 = [1,2,3,1] Output: true 문제 풀이 hash를 이용해서 값을 메모해놓고 hash값이 있으면 true를 반환하면 된다. 그런데 이상하게 sort 하고 검사하는것보다 속도가 늦게 나..
-
[Leetcode] 53. Maximum Subarray 문제풀이Algorithm/문제풀이 2021. 10. 5. 13:16
https://leetcode.com/problems/maximum-subarray/ Maximum Subarray - 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,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. 문제 풀이 연속된 값만 구하면 된다. 연속해서..
-
[Leetcode] 463. Island Perimeter 문제풀이Algorithm/문제풀이 2021. 10. 4. 16:56
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 문제 내용 섬이 하나가 주어지는데 섬의 테두리 길이를 구하는 문제 Example 1: Input: grid = [[0,1,0,0],[1,1,1,0],[0,1,0,0],[1,1,0,0]] Output: 16 Explanation: The perimeter is the 16 yellow stripes ..