IndexOutOfBoundsException triggered | LeetCode Where will the ball fall
Link to the puzzle description https://leetcode.com/problems/where-will-the-ball-fall/description/
I have been fighting with this puzzle for more than a month. Still my code cannot output correctly.
I tried this testcase
Input: grid = [[1,1,1,-1,-1],[1,1,1,-1,-1],[-1,-1,-1,1,1],[1,1,1,1,-1],[-1,-1,-1,-1,-1]]
Output: [1,-1,-1,-1,-1]
And my WIP code (it triggers IndexOutOfBoundsException at line int currRow = 0
. Could anyone kindly point me in the right direction?:
5 Replies
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Like this. I still don't undestand what is out of bound

What's
0 - 1
?
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Similarly, if you have 5 candies and I ask you for candu number -1, it's also out of bounds