# -*- coding:utf-8 -*- class AntiOrder: def count(self, A, n): # write code here num = 0 for i in range(n): l = A[i] for j in range(i,n): m = A[j] if l>m: num+=1 return num
最傻的方法,两次循环,比对找逆序
有更好的方法踢我一下,真想不出了、、、
# -*- coding:utf-8 -*- class AntiOrder: def count(self, A, n): # write code here num = 0 for i in range(n): l = A[i] for j in range(i,n): m = A[j] if l>m: num+=1 return num