leetcode.jp 博客
本网站所有文字及图片内容均来自网络,每周定时更新,仅供个人学习与研究,请勿用于商业用途。谢谢合作。

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

Example:

Input: [0,1,0,3,12]
Output: [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.

Difficulty:

Easy

Lock:

Normal

Company:

Adobe Amazon Apple Bloomberg Cohesity Dell eBay Facebook Goldman Sachs Google Lyft Microsoft Oracle Paypal Qualcomm SAP Uber Walmart Labs Yahoo Yandex Zillow

Solution(Chinese):

LEETCODE 283. Move Zeroes 解题思路分析