What about this solution?


#1

Can anybody explain why below solution is right or wrong?


#2

The question in the solution and given question are not same,
For the shared question, j is reinitialize with 0 but for this question j is never re-initialize which makes the inner execute at most one time.

if you understand python more check the below code:

j=0
n=4
c=0
arr = [5,4,3,2,1]

for i in range(n):
    print 'check',i,j,n
    if i< n:
        while j<n:
		print '#####',i,j,n
		if  arr[i]< arr[j]:
            
            		c += 1
            		print i,j,c
	    		j+=1

		else:
			break
    else:
	break