Closed ajayg415 closed 4 years ago
Problem: Create NxN matrix from an array input
Problem 1: Input: [1], Output: [1] Problem 2: Input: [1, 2], Output: [[1, 2], [0, 0]] Problem 3: Input: [1, 2, 3], Output: [[1, 2], [3, 0]] Problem 4: Input: [1, 2, 3, 4, 5], Output: [[1, 2, 3], [4, 5, 0], [0, 0, 0]]
[1]
[1, 2]
[[1, 2], [0, 0]]
[1, 2, 3]
[[1, 2], [3, 0]]
[1, 2, 3, 4, 5]
[[1, 2, 3], [4, 5, 0], [0, 0, 0]]
const getMatrix = arr => { //code goes here }
Problem: Create NxN matrix from an array input
Problem 1: Input:
[1]
, Output:[1]
Problem 2: Input:[1, 2]
, Output:[[1, 2], [0, 0]]
Problem 3: Input:[1, 2, 3]
, Output:[[1, 2], [3, 0]]
Problem 4: Input:[1, 2, 3, 4, 5]
, Output:[[1, 2, 3], [4, 5, 0], [0, 0, 0]]