← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026Remote

Summary

Uber phone screen for an MLE role, basically one technical problem the whole time. The question was about minimizing a convex function treated as a black box, and it escalated from a continuous 1D version to a discrete 2D rectangle by the end of the round.

Questions Asked (3)

Q1

Given a black-box convex function F(x) defined on a continuous interval [a, b], write a routine to find the minimum using as few evaluations of F as possible.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I went straight to ternary search, which was fine, but the interviewer pushed back on the number of F evaluations per iteration.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use ternary search, which is optimal for finding the minimum of a convex function on an interval, requiring O(log(1/ε)) evaluations. Alternatively, if derivatives are available, use gradient descent or Newton's method, but since it's a black-box, ternary search is the standard. Discuss the trade-offs and mention that ternary search is essentially a derivative-free optimization method.

Pro tip: Mention that ternary search can be improved by using the golden section search, which reuses one evaluation per iteration, reducing the number of function evaluations by about 50% compared to naive ternary search. This shows awareness of practical efficiency.

1. Clarify assumptions and constraints

Confirm that the function is convex, continuous, and unimodal on [a, b]. Ask about the desired precision ε and whether function evaluations are expensive.

2. Choose an algorithm

Select ternary search or golden section search for derivative-free optimization. Explain why they are optimal for convex functions.

3. Describe the algorithm steps

Outline the iterative process: evaluate at two interior points, compare values, and discard the subinterval that cannot contain the minimum. Repeat until interval is small enough.

4. Analyze complexity and precision

State that the number of evaluations is O(log((b-a)/ε)) and discuss how to choose the number of iterations to achieve ε precision.

5. Discuss optimizations and alternatives

Mention golden section search for fewer evaluations, or if derivatives are available, use gradient-based methods. Also note that for high-dimensional problems, other methods are needed.

Key Points to Mention

  • Convexity guarantees a unique minimum and unimodality.
  • Ternary search reduces the interval by 2/3 each iteration, requiring about log_{3/2}((b-a)/ε) evaluations.
  • Golden section search reduces the interval by the golden ratio (~0.618) and reuses one evaluation per iteration, requiring about log_{1/φ}((b-a)/ε) evaluations, which is fewer than ternary search.
  • The number of function evaluations is logarithmic in the inverse of the desired precision.
  • If the function is expensive to evaluate, caching or parallel evaluation might be considered.
  • For non-convex functions, other global optimization methods are needed, but convexity is given.

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

Q2

Now assume F is defined on an integer interval. Can you do better than ternary search? Implement an integer-domain minimizer for a strictly convex function.

Algorithms & Data Structures
Author's notes

This one actually clicked faster for me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Explain that for a strictly convex function on an integer interval, we can use binary search on the discrete derivative (difference) to find the minimum in O(log n) time, which is better than ternary search's O(log n) but with a smaller constant factor. Then implement the algorithm by comparing f(mid) and f(mid+1) to decide which half to discard.

Pro tip: Mention that ternary search does two evaluations per iteration, while binary search on the derivative does one, making it more efficient in practice. Also, handle edge cases like interval size 1 or 2 explicitly to avoid infinite loops.

1. Understand the problem

Clarify that the function is strictly convex on an integer interval, meaning the discrete derivative is strictly increasing. The goal is to find the integer minimizer efficiently.

2. Choose the algorithm

Use binary search on the discrete derivative: compare f(mid) and f(mid+1). If f(mid) < f(mid+1), the minimum is at or left of mid; otherwise, it is right of mid.

3. Implement the search

Initialize low and high bounds. While low < high, compute mid = low + (high - low) // 2. If f(mid) < f(mid+1), set high = mid; else set low = mid + 1. Return low as the minimizer.

4. Handle edge cases

Ensure the loop terminates correctly for intervals of size 1 or 2. Test with small intervals to verify correctness.

5. Analyze complexity

State that the algorithm runs in O(log n) time with O(1) space, and uses one function evaluation per iteration, improving over ternary search's two evaluations.

Key Points to Mention

  • Strict convexity implies the discrete derivative is strictly increasing, enabling binary search.
  • Binary search on the derivative uses one function evaluation per iteration, while ternary search uses two.
  • The algorithm finds the exact integer minimizer, not just an approximate one.
  • Time complexity is O(log n) and space complexity is O(1).
  • Edge cases: interval size 1 (return the only element) and size 2 (compare the two elements).
  • The method works for any strictly convex function, including non-differentiable ones, as long as the discrete derivative is increasing.

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

Q3

Extend the integer-domain minimizer to two dimensions: given a strictly convex f(x, y) over an integer rectangle, find the (x, y) that minimizes f.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Honestly the trickiest part wasn't the code, it was the assumption you have to state before writing anything.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (rectangle size, function properties, evaluation cost) and then propose a solution that extends 1D ternary search to 2D. Explain that for strictly convex functions, you can alternate ternary searches on x and y until convergence, or use nested ternary search. Discuss trade-offs between these approaches and mention potential optimizations like gradient-based methods if derivatives are available.

Pro tip: Emphasize that the number of function evaluations matters in practice, especially if f is expensive to compute. Suggest using a more efficient method like coordinate descent with ternary search or even a 2D version of golden-section search to reduce evaluations.

1. Clarify problem constraints

Ask about the size of the rectangle, whether f is differentiable, and if function evaluations are costly. This determines the appropriate algorithm and its complexity.

2. Propose a baseline approach

Describe nested ternary search: for each x, find the optimal y via ternary search, then ternary search over x. Analyze its time complexity (O(log^2 N) evaluations).

3. Discuss improvements and alternatives

Mention alternating ternary search (coordinate descent) which may converge faster in practice. If gradients are available, consider gradient descent with projection or Newton's method.

4. Analyze trade-offs

Compare methods in terms of number of function evaluations, convergence guarantees, and implementation complexity. Highlight that for strictly convex functions, any local minimum is global.

5. Handle edge cases and implementation details

Discuss termination criteria (e.g., when interval size < 1), integer rounding, and ensuring the search stays within the rectangle bounds.

Key Points to Mention

  • Strict convexity guarantees a unique global minimum and unimodality along any line.
  • Ternary search works for unimodal functions and can be extended to 2D via nested or alternating searches.
  • Time complexity: O(log(max(X,Y))) for alternating search, O(log X * log Y) for nested search.
  • Function evaluation cost may dominate; minimize evaluations by using golden-section search or caching.
  • If gradients are available, gradient-based methods can be more efficient but may require step size tuning.
  • Coordinate descent may get stuck in non-convex functions, but for strictly convex functions it converges to the global minimum.

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