Stores if a position in the matrix been visited or not
vis = new Vector < Vector < Boolean > > ( ) ; for ( int i = 0 ; i < M + 5 ; i ++ ) { vis . add ( new Vector < Boolean > ( ) ) ; for ( int j = 0 ; j < N + 5 ; j ++ ) { vis . get ( i ) . add ( false ) ; } }