본문 바로가기

LeetCode16

287. Find the Duplicate Number c++ 문제 풀이 각 정수가 [1, n] 범위 내에 있는 n + 1 정수를 포함하는 정수 배열을 지정합니다. 숫자로 반복되는 숫자가 하나뿐입니다. 이 반복된 숫자를 반환합니다. 배열 번호를 수정하지 않고 일정한 추가 공간만 사용하여 문제를 해결해야 합니다. Medium 난이도 Example 1: Input: nums = [1,3,4,2,2] Output: 2 Example 2: Input: nums = [3,1,3,4,2] Output: 3 Constraints: 1 2022. 7. 3.
581. Shortest Unsorted Continuous Subarray c++ 문제 https://leetcode.com/problems/shortest-unsorted-continuous-subarray/description/ Shortest Unsorted Continuous 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 Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in asce.. 2022. 6. 23.
162. Find Peak Element c++ 문제 A peak element is an element that is strictly greater than its neighbors. Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that nums[-1] = nums[n] = -∞. You must write an algorithm that runs in O(log n) time. 피크 요소는 이웃보다 엄격하게 큰 요소입니다. 정수 배열 nums가 주어지면 피크 요소를 찾고 해당 인덱스를 반환합니다. 배열에 여러.. 2022. 6. 21.
88. Merge Sorted Array c++ 문제 88. Merge Sorted Array You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate .. 2022. 6. 20.