For example, an array A = [10, 20, 30] and a value x = 25.
We have values 10, 20, 30 at indices 0,1,2 respectively.
So there are 2 valid indices.
Sample Input 1
[1, 2, 3, 5, 7]
13
Sample Output 1
3
def func(array, number):
for i in range(len(array)):
if (array[i] + number) <= sum(array[i+1:] + array[:i]):
del array[i]
return func(array, number)
return print(len(array), 'valid indices.')
Comments
Leave a comment