SHARE
TWEET

Untitled

a guest Oct 15th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   public static int[][] removeRowAndCol(int[][] matrix, int row, int col) {
  2.     int[][] finalMatrix = new int[matrix.length-1][];
  3.     for(int i = 0; i < matrix.length; i++){
  4.       int c = 0;
  5.       int r = 0;
  6.       for(int j = 0; j < matrix[i].length; j++){
  7.         if(i > row)
  8.           r = 1;
  9.         if (j > col)
  10.           c = 1;
  11.        
  12.         if (i != row)
  13.           finalMatrix[i - r] = new int[matrix[i].length < col ? matrix[i].length : matrix[i].length - 1];
  14.         if(i != row && j != col) {
  15.           finalMatrix[i-r][j-c] = matrix[i][j];
  16.         }
  17.       }
  18.     }
  19.    
  20.     return finalMatrix;
  21.   }
  22.  
  23.  
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top