Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 도메인 주도 설계 핵심 #DDD #도메인 주도 설계 #도메인
- DDD #도메인 #도메인 주도 설계 #도메인 주도 섥계 핵심
- aws #cloudwatch #log insight
- codinGame
- 도메인 #도메인 주도 설계 #도메인 주도 설계 핵심 #DDD
- base7
- leetcode #2206. Divide Array Into Equal Pairs
- leetcode #20. Valid Parentheses #알고리즘 #leetcode Valid Parentheses
- leetcode
- codingame #코딩게임 #codingame fall challenge2023 #코딩게임 2023 가을 챌린지
- Fall Challenge 2023
- leetcode #알고리즘 #릿코드
- 반 버논
- LeetCode #
- Longest Substring WIthout Repeating Characters
- #move zeroes
- DDD #도메인 #도메인 주도 설계 #도메인 주도 설계 핵심
- #20. Valid Parentheses java
- 도메인 주도 설계 핵심
- ddd
- 867. Transpose Matrix #Transpose Matrix
- 코딩게임
- Find Pivot Index
Archives
- Today
- Total
목록Find Pivot Index (1)
주하니 서하아빠

문제 풀이방법 pivot 인덱스를 기준으로 왼쪽과 오른쪽의 합의 같을 때의 pivot 인덱스를 반환하는 문제 전체 합을 먼저 구해놓고 앞에서 부터 빼서 왼쪽 합, 오른쪽 합을 비교해서 왼쪽 합과 오른쪽 합이 동일 : 해당 index를 반환 왼쪽 합과 오른쪽 합이 다름 : for문을 계속 순환 var pivotIndex = function(nums) { let total = nums.reduce((a,b) => a+b) let leftSum = 0; for (let i = 0; i < nums.length; i++) { const rightSum = total - leftSum - nums[i]; if (leftSum === rightSum) return i; leftSum += nums[i]; } ret..
알고리즘/LeetCode
2023. 6. 17. 21:25