You are viewing a single comment's thread. Return to all comments →
Python 3 solution. Tests are passed.
def runningTime(A): N= len(A) total = 0 for i in range(1, N): cnt = 0 while A[i-1] > A[i] and i >0: A[i], A[i-1] = A[i-1], A[i] i-=1 cnt+=1 total +=cnt return total
Seems like cookies are disabled on this browser, please enable them to open this website
Running Time of Algorithms
You are viewing a single comment's thread. Return to all comments →
Python 3 solution. Tests are passed.