Loading...
Loading...
Loading...
Temperature changes are listed in non-decreasing order and may be negative. Print the squares of the values in non-decreasing order. Use two pointers; do not call sort.
Example
Input
-7 -3 2 3 11
Output
4 9 9 49 121
Try the problem first. Open one hint at a time.
The largest square is at one of the two ends.
Fill the answer from the back with the larger square and move the pointer that supplied it.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor