Skip to main content
Code Review

Return to Question

Commonmark migration
Source Link

Search in a 2D array to check if there is a column or a row in the 2D Array thats contains all the word "error", if yes return the index of that row or column else return 0;

Exception: if the row index equals the column index then it does not matter if contains the word "error" or not. FYI, n is the size of 2D array (number of rows = number of columns)

Search in a 2D array to check if there is a column or a row in the 2D Array thats contains all the word "error", if yes return the index of that row or column else return 0;

Exception: if the row index equals the column index then it does not matter if contains the word "error" or not. FYI, n is the size of 2D array (number of rows = number of columns)

Search in a 2D array to check if there is a column or a row in the 2D Array thats contains all the word "error", if yes return the index of that row or column else return 0;

Exception: if the row index equals the column index then it does not matter if contains the word "error" or not. FYI, n is the size of 2D array (number of rows = number of columns)

deleted 9 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Search in a 2D Arrayarray to find if there is a row or a column that contains the word "error" in every cell of that row or column

Search in a 2D Array to check if there is a column or a row in the 2D Array thats contains all the word "error", if yes return the index of that row or column else return 0;

Search in a 2D array to check if there is a column or a row in the 2D Array thats contains all the word "error", if yes return the index of that row or column else return 0;

Exception: if the row index equals the column index then it does not matter if contains the word "error" or not. FYI, n is the size of 2D array (number of rows = number of columns)

Exception: if the row index equals the column index then it does not matter if contains the word "error" or not. FYI, n is the size of 2D array (number of rows = number of columns)

I wrote thethis code below and I want to check with you guys if you agree with the logic:

Search in a 2D Array to find if there is a row or a column that contains the word "error" in every cell of that row or column

Search in a 2D Array to check if there is a column or a row in the 2D Array thats contains all the word "error", if yes return the index of that row or column else return 0;

Exception: if the row index equals the column index then it does not matter if contains the word "error" or not. FYI, n is the size of 2D array (number of rows = number of columns)

I wrote the code below and I want to check with you guys if you agree with the logic:

Search in a 2D array to find if there is a row or a column that contains the word "error" in every cell of that row or column

Search in a 2D array to check if there is a column or a row in the 2D Array thats contains all the word "error", if yes return the index of that row or column else return 0;

Exception: if the row index equals the column index then it does not matter if contains the word "error" or not. FYI, n is the size of 2D array (number of rows = number of columns)

I wrote this code and I want to check with you if you agree with the logic:

Source Link
Mike
  • 31
  • 1
  • 1
  • 3

Search in a 2D Array to find if there is a row or a column that contains the word "error" in every cell of that row or column

Search in a 2D Array to check if there is a column or a row in the 2D Array thats contains all the word "error", if yes return the index of that row or column else return 0;

Exception: if the row index equals the column index then it does not matter if contains the word "error" or not. FYI, n is the size of 2D array (number of rows = number of columns)

I wrote the code below and I want to check with you guys if you agree with the logic:

int search(int n, String[][] myArray) {
 int j, k;
 boolean isError;
 //To search per ROW
 for (int i = 1; i <= n; i++) {
 j = 1;
 isError = true;
 while (j <= n && isError) {
 if ((i != j) && (myArray[i][j] != "error")) {
 isError = false;
 }
 if (j == n && isError) {
 return i;
 } else {
 j++;
 }
 }
 }//end for loop
 //To search per COLUMN
 for (int i = 1; i <= n; i++) {
 k = 1;
 isError = true;
 while (k <= n && isError) {
 if ((i != k) && (myArray[k][i] != "error")) {
 isError = false;
 }
 if (k == n && isError) {
 return i;
 } else {
 k++;
 }
 }
 }//end for loop
 return 0;
 }
lang-java

AltStyle によって変換されたページ (->オリジナル) /