Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1.     public int rowAfterDrop(int[][] board, int col){
  2.         if(col > board[0].length - 1 || col < 0) //if col is more then the number of columns or negative
  3.         {
  4.             return -1;
  5.         }
  6.         for(int i = board.length - 1; i >= 0; i--) //for each row
  7.         {
  8.             if(board[i][col] == 0) //in the selected column, if it's empty
  9.             {
  10.                 return i; //return the row to drop in
  11.             }
  12.         }
  13.  
  14.         return -1;
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement