PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Uber

Simulate robot on grid with obstacles

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in simulating stateful movement on a grid, efficient use of data structures for obstacle detection, and analysis of time and space complexity under large input constraints.

  • Medium
  • Uber
  • Coding & Algorithms
  • Software Engineer

Simulate robot on grid with obstacles

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

A robot starts at (0, 0) on an unbounded integer grid. You are given a sequence of commands consisting of characters U, D, L, and R, and a set of blocked cells (obstacles). For each command, the robot attempts to move one cell in the indicated direction; if the destination cell is blocked, it does not move for that command and proceeds to the next. Return the maximum squared Euclidean distance from the origin reached at any time during the simulation. Design an algorithm that handles up to 1e5 commands and 1e5 obstacles efficiently; describe data structures (e.g., hash set for obstacles), complexity, and edge cases.

Quick Answer: This question evaluates proficiency in simulating stateful movement on a grid, efficient use of data structures for obstacle detection, and analysis of time and space complexity under large input constraints.

Related Interview Questions

  • Implement stream queries and bounded-difference subarrays - Uber (medium)
  • Implement Minesweeper and Word Search - Uber (medium)
  • Implement Store Autocomplete - Uber (medium)
  • Simulate a Rank-Based Tournament - Uber (medium)
  • Implement Cache Eviction And Seat Assignment - Uber (medium)
Uber logo
Uber
Jul 15, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
4
0

A robot starts at (0, 0) on an unbounded integer grid. You are given a sequence of commands consisting of characters U, D, L, and R, and a set of blocked cells (obstacles). For each command, the robot attempts to move one cell in the indicated direction; if the destination cell is blocked, it does not move for that command and proceeds to the next. Return the maximum squared Euclidean distance from the origin reached at any time during the simulation. Design an algorithm that handles up to 1e5 commands and 1e5 obstacles efficiently; describe data structures (e.g., hash set for obstacles), complexity, and edge cases.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Software Engineer•Uber Software Engineer•Uber Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,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.