PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Uber

Move zeros to front

Last updated: Apr 2, 2026

Quick Overview

This question evaluates array manipulation and in-place algorithm skills, specifically competency in stable element reordering, index management, and space/time complexity considerations within the Coding & Algorithms domain.

  • medium
  • Uber
  • Coding & Algorithms
  • Data Scientist

Move zeros to front

Company: Uber

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given an integer array `nums`, move all `0` values to the beginning of the array **in place** while preserving the relative order of all non-zero elements. Requirements: - Modify the original array; do not allocate a second array. - Use `O(1)` extra space. - Preserve the relative order of all non-zero values. Example: - Input: `[1, 0, 2, 0, 3]` - Output: `[0, 0, 1, 2, 3]`

Quick Answer: This question evaluates array manipulation and in-place algorithm skills, specifically competency in stable element reordering, index management, and space/time complexity considerations within the Coding & Algorithms domain.

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 18, 2026, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
3
0
Loading...

Given an integer array nums, move all 0 values to the beginning of the array in place while preserving the relative order of all non-zero elements.

Requirements:

  • Modify the original array; do not allocate a second array.
  • Use O(1) extra space.
  • Preserve the relative order of all non-zero values.

Example:

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