Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.
|
|
1. Basic Code Solution
|
|
算法说明:
- 创建results变量存储返回的结果数组;
- 创建一个外部循还遍历外层数组;
- 创建内层循还遍历每一个内层数组,寻找最大值,存储在变量largestNumber中;
- 将每一个内层数组中的最大值保存在results中的相应位置;
- 返回结果数组。
2. Intermediate Code Solution
|
|
3. Advanced Code Solution
|
|