Algorithm37 [LeetCode] Find Pivot Index 목차 문제 pivot 기준 왼쪽의 합과 오른쪽 합이 같아지는 pivot의 인덱스를 구하는 문제입니다. 예시 Input: nums = [1,7,3,6,5,6] Output: 3 Explanation: The pivot index is 3. Left sum = nums[0] + nums[1] + nums[2] = 1 + 7 + 3 = 11 Right sum = nums[4] + nums[5] = 5 + 6 = 11 Input: nums = [1,2,3] Output: -1 Explanation: There is no index that satisfies the conditions in the problem statement. Input: nums = [2,1,-1] Output: 0 Explanation: .. 2024. 4. 8. [LeetCode] Height Checker 목차 문제 heights를 정렬했을 때의 위치와 기존 위치가 같지 않은 개수를 구하는 문제입니다. 예시 Input: heights = [1,1,4,2,1,3] Output: 3 Explanation: heights: [1,1,4,2,1,3] expected: [1,1,1,2,3,4] Indices 2, 4, and 5 do not match. Input: heights = [5,1,2,3,4] Output: 5 Explanation: heights: [5,1,2,3,4] expected: [1,2,3,4,5] All indices do not match. Input: heights = [1,2,3,4,5] Output: 0 Explanation: heights: [1,2,3,4,5] expected: [.. 2024. 4. 8. [LeetCode] Valid Mountain Array 목차 문제 다음 조건을 만족하는지 여부를 체크하는 문제입니다.(산형태가 되어야 함.) arr.length >= 3 There exists some i with 0 arr[i + 1] > ... > arr[arr.length - 1] 예시 Input: arr = [2,1] Output: false Input: arr = [3,5,5] Output: false Input: arr = [0,3,2,1] Output: true 제약조건 1 2024. 4. 8. [LeetCode] Check If N and Its Double Exist 목차 문제 arr안에서 다음 조건을 만족하는 인덱스 쌍이 존재하는지 체크하는 문제입니다. i != j 0 2024. 4. 8. 이전 1 2 3 4 5 6 ··· 10 다음