FastPrepConvex Function Minimization
Problems/Convex Function Minimization

Convex Function Minimization

Uber logoUber● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report describes quadratic optimization and reasoning but omits the formula, interval, interface and numerical rules. This bounded exact-decimal practice contract preserves the reported optimization task; the judged core matches the visible source at about 80%.

You are given a list of queries. Each query is a row [A, B, C, left, right] of five numbers. It describes the curve F(x) = A*x*x + B*x + C, where A > 0, and the closed interval from left to right. For each query, find the value of x in that interval that makes F(x) as small as possible. The value of C does not change where the lowest point is.

For example, the query ["1", "-4", "7", "0", "10"] is the curve x*x - 4*x + 7 on the interval from 0 to 10. The lowest point of the curve is at x = 2, which is inside the interval, so the answer is "2.000000".

Numbers are given as text

Every number is given as decimal text, such as "1", "-0.25" or "+12.50e-3". They are text so that they can be exact. Some numbers are too big or too small for a double, such as 1e400 or 1e-400. Treat each string as its exact decimal value.

How to find the answer

Compute the exact lowest point of the curve, -B/(2*A). If it is outside the interval, move it to the nearest end of the interval. Then round it. Use exact arithmetic for every comparison and for the rounding. Forming 2*A in binary floating point can overflow even when the answer is small and finite.

Return value

Return an array with one string per query, in the same order as queries. If queries is empty, return an empty array.

Each string uses ordinary decimal notation with exactly six digits after the decimal point. Round to the nearest multiple of 0.000001. At an exact halfway point, choose the multiple whose last kept digit is even. For example, 0.0078125 becomes 0.007812, while 0.0234375 becomes 0.023438.

Sign of zero

Keep the sign of the exact value you picked, even when it rounds to zero.

  • The lowest point -B/(2*A) has the opposite sign of the text of B, including a signed zero. So an unmoved lowest point for B = +0 is returned as "-0.000000", and for B = -0 as "0.000000".
  • If the lowest point is moved to an end of the interval, keep the sign written in the text of that end.
  • If the lowest point equals an end of the interval exactly, pick the lowest point, not the text of the end.
  • A negative value that is not zero but rounds to zero keeps its minus sign.

Function

minimizeAll(queries: String[][]) → String[]

Examples

Example 1

queries = [["1", "-4", "7", "0", "10"], ["1", "2", "1", "0", "5"], ["2", "-8", "1", "3", "10"]]return = ["2.000000", "0.000000", "3.000000"]

The first query is the curve x*x - 4*x + 7 on the interval from 0 to 10. Its lowest point is x = 2, which is inside the interval, so the answer is 2.000000. The second query is x*x + 2*x + 1 on the interval from 0 to 5. Its lowest point is x = -1, which is left of the interval, so we move it to the left end, 0, and the answer is 0.000000. The third query is 2*x*x - 8*x + 1 on the interval from 3 to 10. Its lowest point is x = 2, which is left of 3, so the answer is 3.000000. The answer is ["2.000000", "0.000000", "3.000000"].

Constraints

  • 0 <= queries.length <= 50
  • Each queries[i] has exactly five numbers, in the order A, B, C, left, right.
  • All the numbers together have at most 100000 characters.
  • Every number is text made of an optional + or -, at least one digit, an optional decimal point followed by one or more digits, and an optional e or E exponent with an optional sign and digits. Texts such as 1, -0.25 and +12.50e-3 are valid.
  • Each number has at most 400 characters, and its exponent is between -400 and 400. A missing exponent means zero. Leading zeroes are allowed. NaN and infinity are not allowed.
  • A > 0 and left <= right. The numbers can be larger or smaller than any double.
  • Return the lowest position, not the lowest value of F, with six digits after the decimal point and the sign rules above.

More Uber Phone Screen questions

  • Worst-Performing Ads by CTR in a Campaign TreePHONE SCREEN · Seen Nov 2026
  • Earliest Time All Users Are ConnectedPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Max Points on a LinePHONE SCREEN · Seen Oct 2026
  • Meeting Rooms IIPHONE SCREEN · Seen Oct 2026
  • Merge Meeting IntervalsPHONE SCREEN · Seen Oct 2026
  • Minimum Meeting Rooms with AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Find Robots by Blocker DistancesPHONE SCREEN · Seen Oct 2026
  • Sliding-Window Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Count Connected IslandsPHONE SCREEN · Seen Sep 2026
  • Dynamic Island CountsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Square Root FunctionCitadel · PHONE SCREENCitadel interview questions
  • Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Square Root with Newton IterationGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Minimum of a Convex FunctionRippling · PHONE SCREENRippling interview questions
  • Minimum Full Glasses for an Exact Water VolumeMarshall Wace · PHONE SCREENMarshall Wace interview questions
  • Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
  • Percentile and Boundary QueriesDatadog · PHONE SCREENDatadog interview questions
  • Categorical Sampling with Recorded DrawsMicrosoft · PHONE SCREENMicrosoft interview questions
  • Sure Profit on a Horse RaceSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Sqrt(x)LinkedIn · PHONE SCREENLinkedIn interview questions
All Uber interview questionsSee Uber hiring insights
Saved
class Solution {
    public String[] minimizeAll(String[][] queries) {
        // write your code here
    }

}
Checking account…