敘述
這是 Algorithm I 的第二天第一個題目,總共有兩題。
- 難度: 
Easy - 花費時間: 1hr
 - 題目
 
傳入一個陣列(array),把陣列裡的所有數字開平方,然後排序平方完的陣列,之後回傳排序完的陣列。
點我開啟限制與範例
限制:
1 <= nums.length <= 104-104 <= nums[i] <= 104numsis sorted in non-decreasing order.
Example 1:
1  | Input: nums = [-4,-1,0,3,10]  | 
Example 2:
1  | Input: nums = [-7,-3,2,3,11]  | 
筆記
第一種作法: JS 內建函式
這作法算是有點作弊,使用到了兩個 JS 內建函式,分別是:
- Array.prototype.map(): 負責把陣列裡的值平方後傳出。
 - Array.prototype.sort(): 負責排序平方完的陣列。
 
1  | /**  | 
成績
JS 內建函式
