携程笔试题
给定一个整形数组, 将数组中所有的0移动到末尾, 非0项保持不变;
问题描述
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.
实例
For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
注意事项
Note:
1、You must do this in-place without making a copy of the array.
2、Minimize the total number of operations.
#!/usr/bin/env python
# coding:utf-8
""""
Name: 01_携程_移动数组中的0.py
Date: 2018/2018/30
Connect: xc_guofan@163.com
Author: lva