Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- """
- @param nums: A list of integers
- @return: A list of integers includes the index of the first number and the index of the last number
- """
- def subarraySum(self, nums):
- # write your code here
- sums = [0]
- i = 0
- for num in nums:
- sums.append(sums[i]+num)
- i+=1
- for i in range(len(sums)):
- if sums[i] in sums[i+1:]:
- return [i,sums.index(sums[i])-1]
Add Comment
Please, Sign In to add comment