Snail
题目
Snail Sort
Given an n x n array, return the array elements arranged from outermost elements to the middle element, traveling clockwise.
1 | array = [[1,2,3], |
For better understanding, please follow the numbers of the next array consecutively:
1 | array = [[1,2,3], |
NOTE: The idea is not sort the elements from the lowest value to the highest; the idea is to traverse the 2-d array in a clockwise snailshell pattern.
NOTE 2: The 0x0 (empty matrix) is represented as en empty array inside an array
[[]].
分析
看注释
答案
1 | let snail = function (array) { |

