topic:
Press you Non -reduced order Sorting integer array nums
,return Each number square New array of composition,The request is also pressed Non -reduced order Sort。
Exemplary example 1:
enter:nums = [-4,-1,0,3,10] Output:[0,1,9,16,100] explain:After,Array becomes [16,1,0,9,100] Sort后,Array becomes [0,1,9,16,100]
Exemplary example 2:
enter:nums = [-7,-3,2,3,11] Output:[4,9,9,49,121]
hint:
1 <= nums.length <= 104
-104 <= nums[i] <= 104
nums
Pressed Non -reduced order Sort
Advance:
- PleaseDesign time complexity is
O(n)
The algorithm solves this problem
Related Topics
Thought:
I originally planned to write an insertion after each calculation was calculated,The result is timeout。IgnoresortPuzzle。
Code:
1 | class Solution: |