class Solution:
"""
@param nums: The integer array you should partition
@param k: An integer
@return: The index after partition
"""
def partitionArray(self, nums, k):
# write your code here
l, r = 0,len(nums)
i = len(nums) -1
## 反向遍历,类比二分当时找lower_bound
while l <= i:
if nums[i]<k :
nums[i],nums[l]= nums[l],nums[i]
l += 1
elif nums[i] > k:
r -= 1
nums[i],nums[r]= nums[r],nums[i]
print(nums)
i -= 1
else:
i -= 1
return i+1