给定一个长度为 n 的整数数组 nums,请将数组中的所有 0 移动到数组的末尾,同时保持非零元素的相对顺序不变。
请注意,要求在不复制数组的情况下,原地对数组进行操作。
第一行输入一个整数 n,表示数组 nums 的长度。
第二行输入 n 个整数,表示数组 nums 中的元素。
输出 n 个整数,表示将所有 0 移动到末尾后的数组。
相邻两个整数之间用一个空格隔开。
5
0 1 0 3 12
1 3 12 0 0
1
0
0
1<=n<=104
−231<=nums[i]<=231−1
By signing up a CodeFun2000 universal account, you can submit code and join discussions in all online judging services provided by us.