When i submit it is showing 'out of bounds' error but the other solution is getting accepted the only difference is that i have used two one dimensional array and he have used one two dimensional array.
Error submission: 242771431 Accepted submission: 242771679
Please help, why am i getting the error?








According to my logic , your second solution should also be with 'out of bounds' because in the
you are going beyond the index of the variable i = -1 which does not exist.
Here is your corrected solution, I increased the length of the array and also added 2 if
corrected solution