Run time error in 2 test cases

https://ide.codingblocks.com/s/137680 The code works for 2 test cses but showing run error for the other 2.

Hi Tanjul,
There’s a very trivial error in your code which gives arrayoutofbound run time error.
2 3
1 2 3
4 5 6