Skip to content
CampusEduX

Move All Zeros to the End

Easyjavapythonccppjavascript

Given an array of N non-negative integers, move every zero to the end while keeping the relative order of the non-zero elements unchanged.

Input Format

The first line contains an integer N. The second line contains N space-separated non-negative integers.

Output Format

Print the modified array as N space-separated integers on one line.

Related Problems

  • Find the Largest Element
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Find the Smallest Element
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Find the Second Largest Element
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...