FastPrepParse, Normalize, and Combine Polynomials
Problems/Parse, Normalize, and Combine Polynomials

Parse, Normalize, and Combine Polynomials

Squarepoint Capital logoSquarepoint Capital● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Squarepoint Capital phone screen. The report keeps parsing a polynomial, writing it back so it round-trips, combining polynomials, negative coefficients, and a talk about overflow. We chose the grammar, one fixed order for the terms, the rule for adding, the function signature, and the exact result for overflow. Our version is about 75% the same as the reported question.

You are given one or more polynomial strings in polynomials. Each one is valid, uses the single variable x, and has no whitespace. A polynomial is a series of signed terms. A term is either an integer constant, or an integer coefficient followed by x and an optional nonnegative exponent. Some terms: -7, x, -3x, 12x^4. A missing coefficient means 1, and a missing exponent also means 1.

Add all the polynomials together and return the sum as one string in this fixed form:

  • Combine terms that have the same exponent.
  • Leave out terms whose coefficient is zero.
  • List the terms from the highest exponent to the lowest.
  • On terms that contain x, do not write a coefficient of 1 or -1.
  • Write the signs in normalized form, with no whitespace.
  • If every term cancels, return 0.

Every coefficient you read, and every coefficient you get while adding, must fit in a signed 64-bit integer. If a coefficient you read or the result of an addition falls outside that range, stop and return exactly OVERFLOW.

Function

combinePolynomials(polynomials: String[]) → String

Examples

Example 1

polynomials = ["3x^2-x+4","-x^2+5x-4"]return = "2x^2+4x"

Terms with the same power of x are added together. The two constants cancel, so the sum has no constant term.

Example 2

polynomials = ["x^3-x","-x^3+x"]return = "0"

Each term in the first polynomial has its opposite in the second. Every coefficient cancels, so the answer is zero.

Example 3

polynomials = ["9223372036854775807","1"]return = "OVERFLOW"

The first constant is already the largest value a signed 64-bit integer can hold. Adding the second constant goes past that limit, so the answer is OVERFLOW.

Constraints

  • 1 <= polynomials.length <= 200.
  • Every expression is valid under the grammar above and has length from 1 through 2000.
  • Coefficient magnitudes contain at most 20 decimal digits.
  • Every exponent is from 0 through 10^6.

More Squarepoint Capital Phone Screen questions

  • Lazy Filter over a GeneratorPHONE SCREEN · Seen Nov 2026
  • Moving Average of a Data StreamPHONE SCREEN · Seen Nov 2026
  • Newton Square Root to a Guaranteed TolerancePHONE SCREEN · Seen Nov 2026
  • Probability of Consecutive HeadsPHONE SCREEN · Seen Nov 2026
  • Three Points in a Semicircle: Monte Carlo EstimatePHONE SCREEN · Seen Nov 2026
  • Combine Two Index SequencesPHONE SCREEN · Seen Aug 2026
  • Sorted Insertion SnapshotsPHONE SCREEN · Seen Aug 2026
  • Strong and Weak Reference LifecyclePHONE SCREEN · Seen Aug 2026
  • Target Sum Across Two Sorted ArraysPHONE SCREEN · Seen Aug 2026
  • Classify Heap Addresses from a Memory SnapshotPHONE SCREEN · Seen Nov 2025

Similar questions at other companies

  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Spreadsheet With Dependent CellsCharacter.AI · PHONE SCREEN
  • Custom Record and Free-Form Field ParserNetflix · PHONE SCREENNetflix interview questions
  • Toy Language Generic Return-Type InferenceOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Evaluate an Arithmetic Expression Written in WordsBrex · PHONE SCREEN
  • Video Cache Hit Rates from a CSV LogTubi · PHONE SCREEN
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN

Squarepoint Capital interview experiences

  • Squarepoint Capital Data Products First Round: 1 Experience
  • Squarepoint Capital C++ and Python SWE Interviews: 7 Experiences
  • Squarepoint Campus SDE Interviews: 7 Experiences (Part 2 of 2)
  • Squarepoint Capital New Grad SDE OA: 5 Experiences (Part 1 of 2)
All Squarepoint Capital interview questionsSee Squarepoint Capital hiring insights
Saved
class Solution {
    public String combinePolynomials(String[] polynomials) {
      // write your code here
    }
}
Checking account…