leetcode-283
来源:互联网 发布:淘宝卖家怎么评价买家 编辑:程序博客网 时间:2024/05/22 02:00
Move Zeroes
题目
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:
- You must do this in-place without making a copy of the array.
- Minimize the total number of operations.
public void moveZeroes(int[] nums) { int temp; int idx = 0;for (int i = 0; i < nums.length; i++) {if (nums[i] != 0) {temp = nums[idx];nums[idx] = nums[i];nums[i] = temp; idx++;}} }
原题地址
阅读全文
0 0
- Leetcode 283
- Leetcode 283
- leetcode-283
- leetcode 283: Move Zeroes
- leetcode-283-Move Zeroes
- [leetcode 283]Move Zeroes
- LeetCode 283----Move Zeroes
- Leetcode #283 Move Zeroes
- leetcode: (283) Move Zeroes
- [LeetCode 283] Move Zeroes
- Leetcode 283 Move Zeroes
- leetcode 283--Move Zeroes
- LeetCode-----283Move Zeroes
- 【LEETCODE】283-Move Zeroes
- 【LeetCode】283Move Zeroes
- Leetcode #283 Move Zeroes
- LeetCode 283:Move Zeroes
- LeetCode 283:Move Zeroes
- RESTful API详解
- 项目之思(日常更新)
- [解决问题]apache2安装以后无法解析php代码
- 【萌新教程】使用VMware虚拟机安装Redhat6.5+oracle(二)
- caffe中的solver.protxt的test_iter以及test_interval的区别
- leetcode-283
- ulimit -n 修改
- iOS之动态计算UITableViewCell高度技巧(一)
- Pycharm教程(5)——Python快捷键相关设置
- 数据库SQL优化大总结之 百万级数据库优化方案
- 微信小程序文件结构
- ethereum Running in Docker
- ios 调节系统音量
- TCP-IP学习笔记(一)——概述