본문 바로가기

LeetCode17

1299. Replace Elements with Greatest Element on Right Side 1299. Replace Elements with Greatest Element on Right Side Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array. Example 1: Input: arr = [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] Explanation: - index 0 --> the greatest element to the right of index 0 is index 1 (18)... 2021. 7. 6.
941. Valid Mountain Array 941. Valid Mountain Array Given an array of integers arr, return true if and only if it is a valid mountain array. arr.length >= 3 There exists some i with 0 ... > arr[arr.length - 1] Example 1: Input: arr = [2,1] Output: false Example 2: Input: arr = [3,5,5] Output: false Example 3: Input: arr = [0,3,2,1] Output: true Constraints: 1 2021. 7. 6.
1346. Check If N and Its Double Exist 1346. Check If N and Its Double Exist Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M). More formally check if there exists two indices i and j such that : i != j 0 2021. 7. 5.
27. Remove Element 27. Remove Element 특정값을 리스트에서 몽땅 제거하고 그 갯수가 몇개인지 리턴하는 문제 * 새로운 배열 할당하는 것은 금지 ! 배열 안에서 수정하기. Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. Mor.. 2021. 7. 5.
26. Remove Duplicates from Sorted Array 26. Remove Duplicates from Sorted Array 정수 어레이 번호가 감소하지 않는 순서로 정렬된 경우 중복된 요소를 제거하여 각 고유 요소가 한 번만 나타나도록 합니다. 요소의 상대적 순서는 동일하게 유지되어야 합니다. 다른 어레이에 추가 공간을 할당하지 마십시오. 추가 메모리 O(1)를 사용하여 입력 배열이 제자리에서 수정이 되도록 진행해야함. Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept .. 2021. 7. 5.