https://leetcode.com/problems/find-pivot-index
솔루션
class Solution:
def pivotIndex(self, nums: List[int]) -> int:
for index, value in enumerate(nums):
if sum(nums[:index+1]) == sum(nums[index:]):
return index
return -1
'컴퓨터공학 & 정보통신 > 알고리즘 문제 풀이' 카테고리의 다른 글
[LeetCode] 989. Add to Array-Form of Integer (0) | 2023.02.15 |
---|---|
[LeetCode] 278. First Bad Version (0) | 2023.02.13 |
[LeetCode] 205. Isomorphic Strings (0) | 2023.02.13 |
[LeetCode] 167. Two Sum II - Input Array Is Sorted (0) | 2023.02.12 |
[LeetCode] 438. Find All Anagrams in a String (0) | 2023.02.12 |