Failed two test cases in problem array wave print column wise

Here is my code: https://ide.codingblocks.com/s/203914

@princeky4,
Check against this input:

4 5
11 12 13 14 1
21 22 23 24 2
31 32 33 34 3
41 42 43 44 4

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.