Return sorted squares of a sorted array
Company: Uber
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates array-processing and algorithmic optimization skills, including handling negative values, element-wise transformations, and preserving sorted order after mapping.
Constraints
- Inputs are provided as Python literals matching the function signature.
- Return a deterministic exact-match result.
Examples
Input: ([-4,-1,0,3,10],)
Expected Output: [0, 1, 9, 16, 100]
Explanation: Prompt example 1.
Input: ([-7,-3,2,3,11],)
Expected Output: [4, 9, 9, 49, 121]
Explanation: Prompt example 2.
Input: ([0],)
Expected Output: [0]
Explanation: Single zero.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.