본문 바로가기

전체 글19

(LeetCode) 53. Maximum Subarray 출처: 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 접근 방식 1. 정렬되지 않은 숫자 배열이 주어짐. 여기서 원하는 위치부터 원하는 위치까지 더했을 때 가장 큰 값을 만들어야 함. 연속적으로! 2. 예시로 설명하면 다음과 같은 값이 주어졌을 때 연속적으로 4개의 값을 더한 케이스가 가장 크므로 그 값을 리턴 Input: nums = [-2,.. 2022. 6. 10.
(LeetCode) 35. Search Insert Position 출처 : https://leetcode.com/problems/search-insert-position/ Search Insert Position - 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 접근 방식 하나의 배열이 주어지고 이 배열은 유니크한 정수가 오름차순으로 정렬되어 있음. target 정수를 하나 주고 이 target 이 해당 배열의 어느 위치에 들어갈 수 있는가? 를 구하는 문제이다. 따라서 배열과 타겟이 다음과 같이 주어면 값은 5의 자리인 2(.. 2022. 6. 10.
(LeetCode) 26. Remove Duplicates from Sorted Array 출처 : https://leetcode.com/problems/remove-duplicates-from-sorted-array/ Remove Duplicates from 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 접근 방식 1. 배열이 주어짐 (non-decreasing order) # 이게 사실 increasing이랑 뭐가 다른지 몰랐었는데 찾아보니 알게 되었음. 줄어들지 않음을 중복을 허용함([1,2,2,3]) 증가하는 것은 중.. 2022. 6. 10.
(LeetCode) 1. Two Sum 출처 : https://leetcode.com/problems/two-sum/ Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation: Because .. 2022. 6. 10.