题解 | #数组的partition调整#

数组的partition调整

http://www.nowcoder.com/practice/d311bcce968d4d849d998a799bf7492a

n = int(input())
nums = list(map(int, input().split()))
if n < 3:
    print(nums)
    exit()
i = 0
for j in range(1, len(nums)):
    if nums[j] != nums[i]:
        i += 1
        nums[j], nums[i] = nums[i], nums[j]
print(*nums)
全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务