Squares in Order
Easy · Squares in Order
A sensor reports deviations from the norm as integers `readings`, already sorted in non-decreasing order; some of them may be negative. The report needs their squares. Return the squares of all numbers in `readings`, sorted in non-decreasing order. Squaring everything and sorting is easy. Try to do it in O(n) without sorting.…
Solve the problem →