defmoveZeroes(nums): """ Do not return anything, modify nums in-place instead. """ s, e, L = 0, 0, len(nums) while s < L and e < L: # 找0值 while s < e and nums[s] != 0: s += 1 # 找非0值 while e < L and nums[e] == 0: e += 1 if s < L and e < L: nums[s], nums[e] = nums[e], nums[s] s += 1 e += 1
Copyright:
Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.