← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

Uber ML engineer screen, just one coding question the whole time. Pretty straightforward problem on paper but I second-guessed myself more than I should have.

Questions Asked (1)

Q1

Given an integer array, find the index of the first local minimum. A local minimum is an element strictly smaller than its immediate neighbors, with edge cases handled for the first and last positions. Return -1 if none exists.

Algorithms & Data Structures
Author's notes

I jumped straight to binary search because I'd seen similar problems before, then realized mid-explanation that the problem asks for the FIRST local minimum by index, not just any one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the definition of local minimum, especially edge cases, then propose a single-pass O(n) scan that checks each element against its neighbors. Walk through the algorithm with examples and discuss time/space complexity.

Pro tip: Explicitly handle edge cases (array length 0, 1, 2) and mention that a local minimum always exists in an array of distinct elements, but with duplicates you may need to define strict inequality carefully.

1. Clarify requirements and edge cases

Ask about array size, duplicates, and whether the first/last elements can be local minima. Confirm the definition of 'immediate neighbors' for edges.

2. Outline the algorithm

Propose a linear scan: for each index i, compare arr[i] with arr[i-1] (if exists) and arr[i+1] (if exists). Return i if both comparisons satisfy strict inequality.

3. Handle edge cases explicitly

For i=0, only compare with arr[1]; for i=n-1, only compare with arr[n-2]. Also handle empty array and single-element array (which is trivially a local minimum).

4. Analyze complexity

State that the algorithm runs in O(n) time and O(1) space, which is optimal since any element could be the first local minimum.

5. Test with examples

Walk through a few examples (e.g., [3,2,1,4], [1,2,3], [2,1,2]) to verify correctness and edge case handling.

Key Points to Mention

  • Definition of local minimum with strict inequality
  • Edge cases: empty array, single element, two elements
  • Linear scan approach with O(n) time and O(1) space
  • Handling first and last positions separately
  • Return -1 if no local minimum found
  • Potential for early termination when found

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.