Return sorted values after quadratic transform
Company: Two Sigma
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: nan
Interview Round: Technical Screen
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.
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
- A quadratic over a sorted array is monotonic away from its vertex.
- Use two pointers at the ends.