Evaluate a Polynomial
Updated
Problem statement
You are given a nonempty integer array coefficients and an integer x. Return the exact value of the polynomial at x.
The coefficients are in ascending power order: coefficients[i] multiplies x^i. If d = coefficients.length-1, evaluate P(x) = coefficients[0] + coefficients[1]*x + ... + coefficients[d]*x^d.
The exponent-zero contribution is the constant coefficient, including when x = 0. A single coefficient represents a constant polynomial. Zero coefficients, including zero final entries, are allowed.
This exercise evaluates the polynomial value only. It does not define a financial rate, cash-flow formula, root search or minimization task.
Do not change coefficients. Use fresh local state for each call. Return one exact integer without a modulus or floating-point tolerance.
Function
evaluatePolynomial(coefficients: int[], x: int) → intExamples
Example 1
coefficients = [2,-3,4]x = 2return = 12The polynomial is 2-3*x+4*x^2. At x=2, its value is 2-6+16 = 12.
Example 2
coefficients = [5,0,-2,1]x = -2return = -11The polynomial is 5-2*x^2+x^3. At x=-2, the terms give 5-8-8 = -11.
Example 3
coefficients = [7,-4,3]x = 0return = 7At x=0, every positive-power contribution is zero. The constant coefficient is 7, so return 7.
Constraints
1 <= coefficients.length <= 9.- Every element of
coefficientsis an integer between-100and100, inclusive. xis an integer with-5 <= x <= 5.- The absolute value of the result and every polynomial partial sum is at most
100*(1+5+...+5^8) = 48828100, which fits a signed 32-bit integer.
More Akuna Capital Phone Screen questions
- Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Biased Coin: Probability of Exactly h HeadsPHONE SCREEN · Seen Nov 2026
- Positive Nth Root with Gradient DescentPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Two SumOA · PHONE SCREEN · Seen Sep 2026
- Maximum Value in a Binary TreePHONE SCREEN · Seen Sep 2026
- Tiered Expiring Item StorePHONE SCREEN · Seen Aug 2026
- Statistics for the Latest K ValuesPHONE SCREEN · Seen Nov 2025
- Remove Duplicates While Preserving OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2025
- Sliding Window MaximumPHONE SCREEN · Seen Oct 2025
- Reverse Nodes in Groups of KPHONE SCREEN · Seen Oct 2025
Similar questions at other companies
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
- Length of a Document Reached Through a Random TokenMercor · PHONE SCREENMercor interview questions
- Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
- Exponential Backoff DelaysWonderful · PHONE SCREEN
- One-Nearest-Neighbor Classification with Manhattan DistanceOpenAI · PHONE SCREENOpenAI interview questions
- Recover Document Hierarchy from IndentationReducto · PHONE SCREEN
- Average Grades per StudentHartford Financial Services · PHONE SCREENHartford Financial Services interview questions
- Through-Origin Linear RegressionMeta · PHONE SCREENMeta interview questions
- Latency Bucket CounterDatadog · OA · PHONE SCREENDatadog interview questions
Akuna Capital interview experiences
- Akuna Capital Quant Trader and QR Interviews: 5 Experiences
- Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
- Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
- Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
- Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
- Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)