Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- An array has a special property which is the following:
- Every number which is ahead of another is bigger than the sum of the previous ones.
- Could you write a function to verify if this specific array exhibits this property?
- Example array:
- 1, 2, 4, 8, 30
- Solution, pseudocode:
- function verify(array):
- sum = 0
- for(i = 0; i < array.length; i++):
- if sum > array[i]:
- return false
- sum += array[i]
- return true
- Solution, python:
- def verify(array):
- sum = 0
- for i in array:
- if sum > i:
- return false
- sum += i
- return true
Advertisement
Add Comment
Please, Sign In to add comment