A reduced version of Problem 112

Given a column vector v, return a vector w in which all the zeros have "bubbled" to the top. The order of the remaining nonzero numbers in the vector should be preserved.

Example:

Input  v = [1
            3
            0
            5
            0
            -1]
Output w = [0
            0
            1
            3
            5
            -1]

Solution Stats

914 Solutions

191 Solvers

Last Solution submitted on Dec 07, 2025

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers191

Suggested Problems

More from this Author25

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!