Squares of a Sorted Array

Easy
ArrayTwo PointersSortingGoogleAmazon
Given a nondecreasing array, square each value and print the squares in nondecreasing order. Input format: - First line: n - Second line: n sorted integers

Constraints

1 <= n <= 10^5
-10^4 <= nums[i] <= 10^4

Sample tests

Sample 1

Sample 2

Sign in to submit