Algorithm · Uber · Medium
You are given an integer array nums that is already arranged in nondecreasing order, along with an integer k. Square every element of nums, and report the k least values among those squares, listed in nondecreasing order. The array may contain negative numbers, so the squares are not necessarily in sorted order. Your solution must not build the full list of squared values and sort it. Input format: the first line holds two integers n k. The second line holds the n elements…