Despite and code is running properly im unable to pass all test cases.PLz look into it.
Unable to pass all test cases
your code doesn’t work for cases with n!=m
Mam Im not getting the correct output after making changes array index out of bound error is shown.