Explained Short Javascript O(n) Beats 100%
\n```\nvar allCellsDistOrder = function(R, C, r0, c0) {\n\t// Create a 2D array which holds the maximum number of possible distances.\n    let ordered = [...Arr
\n```\nvar allCellsDistOrder = function(R, C, r0, c0) {\n\t// Create a 2D array which holds the maximum number of possible distances.\n    let ordered = [...Array(R*C)].map(e => [])\n\t\n\t//  Traverse the whole grid\n    for(let j = 0; j < R; j++) {\n        for(let i = 0; i < C; i++) {\n\t\t\t// Get Manhattan distance\n            let d = Math.abs(j-r0) + Math.abs(i-c0)\n\t\t\t// Add to the 2D array in an ordered manner\n            ordered[d].push([j,i])\n        }\n    }\n    // Use ES6 spread operator to flatten\n    return [].concat([].concat(...ordered))\n};
[]