1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
class : """ @param nums: A list of integer which is 0, 1 or 2 @return: nothing """ def sortColors(self, a): pl, pr = 0, len(a)-1 i = 0 while i <= pr: if a[i] == 0: a[pl], a[i] = a[i], a[pl] i+=1 pl+=1 elif a[i] == 1: i += 1 else: a[pr], a[i] = a[i], a[pr] pr-=1
|
近期评论