Given arr1 = [[0,0,0,0],[0,0,0,0],[0,0,0,0] and arr2 = [[1,2],[3,4],[4,5]] and positions = [0,1,2] we wish to add elements of arr2 to elements of elements of arr1 at the indices specified by postions that is our answer should be [[1,2,0,0],[0,3,4,0],[0,0,4,5]] Note that we guarantee beforehand that the position would be valid.
A simple for loop over the outer array solution works but is pretty slow for my application. I tried using splicing and specifing positions but nothing seems to work.