For rectangle matrix

what is 2d array is not square matrix this code wont work so can you pls provide me code for rectangle matrix…

in O(1) SPACE COMPLEXITY…

@Rupesh-1984 this question is for square matrix only for rectangle o(1) space not possible