Sort Transformed Array
Input:
nums =
[-4,-2,2,4]
, a =
1
, b =
3
, c =
5
Output:
[3,9,15,33]Input:
nums =
[-4,-2,2,4]
, a =
-1
, b =
3
, c =
5
Output:
[-23,-5,1,7]Last updated
Input:
nums =
[-4,-2,2,4]
, a =
1
, b =
3
, c =
5
Output:
[3,9,15,33]Input:
nums =
[-4,-2,2,4]
, a =
-1
, b =
3
, c =
5
Output:
[-23,-5,1,7]Last updated
class Solution:
def sortTransformedArray(self, nums: List[int], a: int, b: int, c: int) -> List[int]:
nl = map(lambda x: a*x**2 + b*x+c, nums)
return sorted(nl)