PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of mathematical transformations and array manipulation, specifically how applying a quadratic function affects the ordering of a sorted sequence.

  • nan
  • Two Sigma
  • Coding & Algorithms
  • Data Scientist

Return sorted values after quadratic transform

Company: Two Sigma

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: nan

Interview Round: Technical Screen

## Problem You are given a sorted integer array `nums` (non-decreasing order) and integers `a`, `b`, `c` that define a quadratic function: \[ f(x) = ax^2 + bx + c \] Apply the function to every element in `nums`, producing an array `res[i] = f(nums[i])`. Return `res` in **sorted (non-decreasing) order**. ### Input - `nums`: sorted array of integers - `a`, `b`, `c`: integers ### Output - A sorted array containing `f(x)` for each `x` in `nums` ### Constraints - `1 <= len(nums) <= 2 * 10^5` - `-10^4 <= nums[i], a, b, c <= 10^4` ### Example - Input: `nums = [-4,-2,2,4], a = 1, b = 3, c = 5` - Output: `[3,9,15,33]`

Quick Answer: This question evaluates understanding of mathematical transformations and array manipulation, specifically how applying a quadratic function affects the ordering of a sorted sequence.

Apply f(x)=ax^2+bx+c to sorted nums and return the transformed values in sorted order.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([-4,-2,2,4], 1, 3, 5)

Expected Output: [3, 9, 15, 33]

Explanation: Upward parabola fills output from largest to smallest.

Input: ([-4,-2,2,4], -1, 3, 5)

Expected Output: [-23, -5, 1, 7]

Explanation: Downward parabola fills output from smallest to largest.

Input: ([0,1,2], 0, 2, 1)

Expected Output: [1, 3, 5]

Explanation: Linear transforms are handled by the same logic.

Hints

  1. A quadratic over a sorted array is monotonic away from its vertex.
  2. Use two pointers at the ends.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Implement Price-Time Order Matching - Two Sigma (medium)
  • Compute Piecewise Linear Interpolation - Two Sigma (medium)
  • Implement an In-Memory Database - Two Sigma (hard)
  • Merge two sorted linked lists - Two Sigma (hard)
  • Merge Two Sorted Lists - Two Sigma (hard)