Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 484 Bytes

File metadata and controls

18 lines (13 loc) · 484 Bytes

Problem 5: Gravity Shift

Problem Statement

Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. You must do this in-place without making a copy of the array.

Input Format

  • An array of integers nums.

Output Format

  • The modified array nums.

Constraints

  • 1 <= nums.length <= 10^4
  • -2^31 <= nums[i] <= 2^31 - 1

Example

Input: nums = [0, 1, 0, 3, 12]
Output: [1, 3, 12, 0, 0]