
Given matrix A and integer B, return new matrix where each element is multiplied by B.
Input: A = [[1,2],3,4], B = 2
Output: [[2,4],6,8]
Iterate through all elements, multiply by scalar.
function scalarMultiply(A, B) {
return A.map(row => row.map(val => val * B));
}

I'm Rahul, Sr. Software Engineer (SDE II) and passionate content creator. Sharing my expertise in software development to assist learners.
More about me