PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Uber

Move zeros to the front

Last updated: Mar 29, 2026

Quick Overview

This question evaluates array manipulation and in-place algorithm competencies, including handling space-time trade-offs and preserving relative order (stability) while operating with O(1) extra space.

  • medium
  • Uber
  • Coding & Algorithms
  • Data Scientist

Move zeros to the front

Company: Uber

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given an integer array `nums`. Reorder the array in place so that all `0` values are moved to the beginning of the array, while preserving the relative order of all non-zero elements. Requirements: - The transformation must be done in place. - Use only `O(1)` extra space. - The relative order of non-zero elements must remain unchanged. Example: - Input: `[4, 0, 5, 0, 3]` - Output: `[0, 0, 4, 5, 3]`

Quick Answer: This question evaluates array manipulation and in-place algorithm competencies, including handling space-time trade-offs and preserving relative order (stability) while operating with O(1) extra space.

Related Interview Questions

  • Maximize Throughput and Count Trigger Components - Uber (medium)
  • Replace Dashes With Nearest Letters - Uber (medium)
  • Find Earliest Column With One - Uber (easy)
  • Solve Wonderful Strings and Grid Queries - Uber (hard)
  • Count Islands After Land Additions - Uber (medium)
Uber logo
Uber
Jan 30, 2026, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
3
0
Loading...

You are given an integer array nums. Reorder the array in place so that all 0 values are moved to the beginning of the array, while preserving the relative order of all non-zero elements.

Requirements:

  • The transformation must be done in place.
  • Use only O(1) extra space.
  • The relative order of non-zero elements must remain unchanged.

Example:

  • Input: [4, 0, 5, 0, 3]
  • Output: [0, 0, 4, 5, 3]

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Data Scientist•Uber Data Scientist•Uber Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.