Algorithm · Uber · Medium
Given an integer array nums whose elements are arranged in non-decreasing order, produce an array containing the square of every element, with the resulting values also ordered non-decreasingly. Your approach must run in linear time rather than squaring all values and sorting the result afterward. Examples Example 1: Input: nums = [-4,-1,0,3,10] Output: [0,1,9,16,100] Explanation: Squaring the input produces [16,1,0,9,100], which becomes [0,1,9,16,100] when ordered. Example…
Checking your access…