PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Uber

Find smallest start index avoiding left exit

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to analyze reachability and cycle behavior in array-based functional graphs, testing competency in array manipulation, traversal, loop detection, and runtime optimization within the Coding & Algorithms domain.

  • easy
  • Uber
  • Coding & Algorithms
  • Software Engineer

Find smallest start index avoiding left exit

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Onsite

You are given an integer array `jump` of length `n` (0-indexed). If you are currently at index `i`, your next position becomes `i + jump[i]` (a positive value moves right, a negative value moves left). Starting from an index `s`, you repeatedly apply this move rule. - If you ever reach an index `< 0`, you have moved out of the **left boundary**. - If you reach an index `>= n`, you have moved out of the array on the right (you may treat this as stopping). - The process may also loop inside the array. Return the **smallest** starting index `s` such that, during the entire process starting from `s`, you **never** move out of the left boundary (i.e., the sequence of visited indices never becomes negative). If no such index exists, return `-1`. Implement an algorithm that runs in O(n) time if possible.

Quick Answer: This question evaluates a candidate's ability to analyze reachability and cycle behavior in array-based functional graphs, testing competency in array manipulation, traversal, loop detection, and runtime optimization within the Coding & Algorithms domain.

Related Interview Questions

  • Implement Minesweeper and Word Search - Uber (medium)
  • Implement Store Autocomplete - Uber (medium)
  • Implement Cache Eviction And Seat Assignment - Uber (medium)
  • Schedule Non-Overlapping Meetings Efficiently - Uber (hard)
  • Evaluate an Arithmetic Expression - Uber
Uber logo
Uber
Dec 30, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
3
0

You are given an integer array jump of length n (0-indexed). If you are currently at index i, your next position becomes i + jump[i] (a positive value moves right, a negative value moves left).

Starting from an index s, you repeatedly apply this move rule.

  • If you ever reach an index < 0 , you have moved out of the left boundary .
  • If you reach an index >= n , you have moved out of the array on the right (you may treat this as stopping).
  • The process may also loop inside the array.

Return the smallest starting index s such that, during the entire process starting from s, you never move out of the left boundary (i.e., the sequence of visited indices never becomes negative). If no such index exists, return -1.

Implement an algorithm that runs in O(n) time if possible.

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.