+ 2

TOWER HOPPER

I have implemented a solution using naive recursion without Dynamic programming. Can we make it better? def minJump(arr,i,j): min = float('inf') if i==j: return 0; if i>j: return float('inf'); else: for x in range(1,arr[i]+1): ans=minJump(arr,x+i,j) if ans!=float('inf') and ans+1 < min: min=ans+1 return min arr =[1, 0] #test purpose print(minJump(arr,0,len(arr)-1))

14th Jul 2018, 3:51 PM
####
#### - avatar
1 Odpowiedź
0
You should post original code
17th Aug 2019, 1:35 PM
a a
a a - avatar