Algorithm
-
[Leetcode] 923. 3Sum With Multiplicity 문제 풀이Algorithm/문제풀이 2022. 4. 6. 13:38
https://leetcode.com/problems/3sum-with-multiplicity/ 3Sum With Multiplicity - 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개의 합이 target이 되는 경우의 수가 몇개 있는 지 찾는 문제 Example 1: Input: arr = [1,1,2,2,3,3,4,4,5,5], target = 8 Output: 20 Explanation: Enumerating by the ..
-
[Leetcode] 31. Next Permutation 문제 풀이Algorithm/문제풀이 2022. 4. 5. 22:21
https://leetcode.com/problems/next-permutation/ Next Permutation - 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 문제 내용 배열이 주어지는 데 해당 배열에서 사전순으로 생각했을 때 다음 Permutation을 출력하는 문제 Example 1: Input: nums = [1,2,3] Output: [1,3,2] Example 2: Input: nums = [3,2,1] Output: [1,2,3] Example..
-
[Leetcode] 1721. Swapping Nodes in a Linked List 문제 풀이Algorithm/문제풀이 2022. 4. 4. 18:05
https://leetcode.com/problems/swapping-nodes-in-a-linked-list/ Swapping Nodes in a Linked List - 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 문제 내용 index 0(왼쪽)부터 시작했을 때 k번째 node와 index size-1 (오른쪽)부터 시작했을 때 k번째 node를 swap하는 문제 Example 1: Input: head = [1,2,3,4,5], k = 2 Output: ..
-
[Leetcode] 540. Single Element in a Sorted Array 문제풀이Algorithm/문제풀이 2021. 11. 20. 21:51
https://leetcode.com/problems/single-element-in-a-sorted-array/ Single Element in a 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개씩 중복되는 숫자가 있다. 1개만 중복 안되는 숫자로 구성되어 있는데 이 숫자를 구하는 문제 Example 1: Input: nums = [1,1,2,3,3,4,4,8,8] Output: 2..
-
[Leetcode] 75. Sort Colors 문제풀이Algorithm/문제풀이 2021. 10. 27. 20:40
https://leetcode.com/problems/sort-colors/ Sort Colors - 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 문제 내용 컬러가 0,1,2 로 있는데 추가적인 공간을 사용하지 않고 정렬하는 문제이다. Example 1: Input: nums = [2,0,2,1,1,0] Output: [0,0,1,1,2,2] 문제 풀이 숫자가 3개밖에 없기 때문에 왼쪽에는 0을 몰아주고 오른쪽에는 2를 몰아주는 방식으로 정렬하면 된다. cla..
-
[Leetcode] 155. Min Stack 문제풀이Algorithm/문제풀이 2021. 10. 25. 14:57
https://leetcode.com/problems/min-stack/ Min Stack - 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 문제 내용 stack을 구현하는 데 min값을 바로 찾을 수 있는 메서드도 구현하는 문제 Example 1: Input ["MinStack","push","push","push","getMin","pop","top","getMin"] [[],[-2],[0],[-3],[],[],[],[]] Output [null,null,n..
-
[Leetcode] 543. Diameter of Binary Tree 문제풀이Algorithm/문제풀이 2021. 10. 11. 11:27
https://leetcode.com/problems/diameter-of-binary-tree/ Diameter of Binary 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 문제 내용 트리의 지름을 구하는 문제 Example 1: Input: root = [1,2,3,4,5] Output: 3 Explanation: 3 is the length of the path [4,2,1,3] or [5,2,1,3]. 문제 풀이 트리의 지름을 구하기 위해..
-
[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..