Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active March 17, 2022 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/02f252a9d51a0c6950440345bdfe4ee4 to your computer and use it in GitHub Desktop.
Save McLarenCollege/02f252a9d51a0c6950440345bdfe4ee4 to your computer and use it in GitHub Desktop.
Traverse Array Columnwise

Given an multi-dimensional array, traverse the array column-wise and push the maximum value of every column into a result array. The function should return the result array.

function traverseColumnwise(arr){
// write your code here
}
let arr1 = [[11, 2, 3],
            [ 4,15, 6],
            [ 7, 8, 9]];
let arr2 = [[ 1, 2, 3,44],
            [25, 6, 7, 8],
            [ 9,10,11,12],
            [13,14,15,16]];
traverseColumnwise(arr1);//[11, 15, 9]
traverseColumnwise(arr2);// [25, 14, 15, 44]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment