본문 바로가기

LeetCode10

1. Two Sum Leetcode 문제 brute force 방식으로 풀었다. 어렵지 않게 이해할 수 있는 코드이다. class Solution { public: vector twoSum(vector& nums, int target) { vector v; for(int i = 0 ; i < nums.size() ; i++) { for(int j = i+1 ; j 2022. 7. 4.
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.
75. Sort Colors LeetCode C++ https://leetcode.com/problems/sort-colors/description/ 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 Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, .. 2022. 6. 20.