I came across this problem through commonlounge and I thought it was a textbook DP problem and many people seem to have done it that way. However, only 3 test cases passed for me and the rest are showing TLE even though I have memoized the solution. Please help me understand why the time limit is being excited and any feedback will be greatly appretiated!
Here is my code:
n = int(input())
arr = list(map(int,input().split()))
memo = [None for i in range (n)]
i = 0