Complete the function below. The function receives the full standard input as a single string and returns the exact standard output lines.
Problem
You are given access to a black-box convex or unimodal function on a closed interval [a, b]. In this text version, the black-box function is represented as a quadratic F(x) = ax^2 + bx + c, and you must find the approximate x in the search interval that minimizes F(x).
For each query, output the minimizing x rounded to exactly six digits after the decimal point. If the unconstrained minimizer lies outside the interval, clamp it to the nearest endpoint.
This models the interview task where the only allowed operation is evaluating the black-box function; ternary search is the intended general approach.
Complete solveConvexFunctionMinimization. It has one parameter, String input. The first line is q. Each of the next q lines contains A B C left right for F(x)=A*x*x+B*x+C on interval [left, right]. Return one rounded minimizer per query.
input = "3\n1 -4 7 0 10\n1 2 1 0 5\n2 -8 1 3 10" return = ["2.000000","0.000000","3.000000"]
The unconstrained minimizers are 2, -1, and 2 respectively; the second and third are clamped to their intervals.
Each query describes a convex quadratic with A > 0.
Return answers rounded to exactly six decimal places.
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026
- Maximal Square AreaONSITE INTERVIEW · Seen May 2026
- First Unique IP Hitting the ServerPHONE SCREEN · Seen May 2026
- Jump Game with Prime-Step RuleOA · Seen May 2026
- Pipeline Throughput Maximization Under BudgetOA · Seen May 2026
public String[] solveConvexFunctionMinimization(String input) {
// write your code here
}