剑指offer python版 数组中的逆序对

def aa(nums):
    if not nums:
        return False
    leng=len(nums)-1
    ret=[]
    for i in range(leng):
        for j in range(i,leng):
            if nums[i]>nums[j]:
                ret.append([nums[i],nums[j]])
            j +=1
            
            
    return ret

print(aa([2,3,3,4,2,2,1,4,5,2]))

 

posted @ 2018-10-29 09:35  findtruth123  阅读(665)  评论(1编辑  收藏  举报