Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int rowAfterDrop(int[][] board, int col){
- if(col > board[0].length - 1 || col < 0) //if col is more then the number of columns or negative
- {
- return -1;
- }
- for(int i = board.length - 1; i >= 0; i--) //for each row
- {
- if(board[i][col] == 0) //in the selected column, if it's empty
- {
- return i; //return the row to drop in
- }
- }
- return -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement