Sort Transformed Array
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given an integer array nums sorted in ascending order and integers a, b, c. Apply
f(x) = a*x^2 + b*x + c to every element.
Return the transformed values sorted in ascending order. Duplicates are kept.
Try to do it in O(n) time instead of sorting again: a quadratic changes direction at most once, so the
largest (or smallest) values sit at the ends of nums.
Examples
Constraints
- 0 <= nums.length <= 200
- -100 <= nums[i], a, b, c <= 100
- `nums` is sorted in ascending order
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.