题目:

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].

python中没有自增运算符++.

  1. class Solution(object):
  2. def moveZeroes(self, nums):
  3. index =
  4. size = len(nums)
  5. for i in range(size):
  6. if nums[i] == :
  7. continue
  8. else:
  9. nums[index] = nums[i]
  10. index +=
  11. while index < size:
  12. nums[index] =
  13. index +=

Leetcode 283 Move Zeroes python的更多相关文章

  1. LN : leetcode 283 Move Zeroes

    lc 283 Move Zeroes 283 Move Zeroes Given an array nums, write a function to move all 0's to the end ...

  2. 283. Move Zeroes@python

    Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...

  3. [LeetCode] 283. Move Zeroes 移动零

    Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...

  4. LeetCode 283. Move Zeroes (移动零)

    Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...

  5. leetcode 283. Move Zeroes -easy

    题目链接:https://leetcode.com/problems/move-zeroes/ 题目内容: Given an array nums, write a function to move ...

  6. LeetCode 283 Move Zeroes 解题报告

    题目要求 Given an array nums, write a function to move all 0's to the end of it while maintaining the re ...

  7. Java [Leetcode 283]Move Zeroes

    题目描述: Given an array nums, write a function to move all 0's to the end of it while maintaining the r ...

  8. 11. leetcode 283. Move Zeroes

    Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...

  9. [leetcode]283. Move Zeroes移零

    Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...

随机推荐

  1. 读jquery.cookie.js源码学到的几个技巧

    一.兼容AMD.CommonJS和普通JS的写法 (function (factory) { if (typeof define === 'function' && define.am ...

  2. symfony2路径问题

    1.相对路径 例:在上传文件里面,路径设置为 $path = "upload/"   此时路径指向的是web/upload/; 2.绝对路径 例:$path = "/va ...

  3. oc语言--description方法和sel

    一.description方法 Description方法包括类方法和对象方法.(NSObject类所包含) (一)基本知识 -description(对象方法) 使用NSLog和@%输出某个对象时, ...

  4. Can't create/write to file '/tmp/#sql_3105_0.MYI' (Errcode: 13)

    最近的项目中由于临时存储空间太大了.索性把tmp目录删除了.结果访问出现 Can't create/write to file '/tmp/#sql_3105_0.MYI' (Errcode: 13) ...

  5. 【iOS开发】collectionView 瀑布流实现

    一.效果展示 二.思路分析 1> 布局的基本流程 当设置好collectionView的布局方式之后(UICollectionViewFlowLayout),当系统开始布局的时候,会调用 pre ...

  6. Linux下安装Perl和Perl的DBI模块

    今天在虚拟机测试shell脚本的时候,有些命令使用不了. 比如说 mysqlhotcopy ,它提示Perl的版本太低. 我用的 RedHat9 的Perl才5.8.0版本...(2002年以前的) ...

  7. ## GridView 布局:item设置的高度和宽度不起作用、自动适配列数、添加Header和Footer ##

    一.item设置的高度和宽度不起作用 转自:http://www.cnblogs.com/0616--ataozhijia/p/6031875.html [Android Pro] listView和 ...

  8. cf479D Long Jumps

    D. Long Jumps time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  9. 大数据时代的数据存储,非关系型数据库MongoDB(一)

    原文地址:http://www.cnblogs.com/mokafamily/p/4076954.html 爆炸式发展的NoSQL技术 在过去的很长一段时间中,关系型数据库(Relational Da ...

  10. mobile web retina 下 1px 边框解决方案

    本文实际上想说的是ios8下 1px解决方案. 1px的边框在devicePixelRatio = 2的retina屏下会显示成2px,在iphone 6 plug 下,更显示成3px.由其影响美感. ...