PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Uber

Implement binary search variants

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding and implementation of binary search variants, focusing on iterative and recursive algorithm design, boundary handling, duplicate occurrence detection (first/last), loop invariants, and formal correctness reasoning.

  • Medium
  • Uber
  • Coding & Algorithms
  • Software Engineer

Implement binary search variants

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Implement binary search on a sorted integer array without using library functions. Provide both iterative and recursive versions that: (a) return the index of the target if present; (b) otherwise return the insertion index that would keep the array sorted. Clarify your loop invariants and boundary handling, support finding the first and last occurrence when duplicates exist, and prove correctness. State time and space complexity.

Quick Answer: This question evaluates understanding and implementation of binary search variants, focusing on iterative and recursive algorithm design, boundary handling, duplicate occurrence detection (first/last), loop invariants, and formal correctness reasoning.

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
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
7
0

Implement binary search on a sorted integer array without using library functions. Provide both iterative and recursive versions that: (a) return the index of the target if present; (b) otherwise return the insertion index that would keep the array sorted. Clarify your loop invariants and boundary handling, support finding the first and last occurrence when duplicates exist, and prove correctness. State time and space complexity.

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.