sqy201x's picture
Publish humaneval: 164 task(s) (openai/openai_humaneval)
b83572f verified
Raw
History Blame Contribute Delete
468 Bytes
def can_arrange(arr):
"""Create a function which returns the largest index of an element which
is not greater than or equal to the element immediately preceding it. If
no such element exists then return -1. The given array will not contain
duplicate values.
Examples:
can_arrange([1,2,4,3,5]) = 3
can_arrange([1,2,3]) = -1
"""
ind=-1
i=1
while i<len(arr):
if arr[i]<arr[i-1]:
ind=i
i+=1
return ind