mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-21 02:53:15 +08:00
Refactor Code Style (#4151)
This commit is contained in:
@ -28,9 +28,9 @@ public class SaddlebackSearch {
|
||||
* @return The index(row and column) of the element if found. Else returns
|
||||
* -1 -1.
|
||||
*/
|
||||
private static int[] find(int arr[][], int row, int col, int key) {
|
||||
private static int[] find(int[][] arr, int row, int col, int key) {
|
||||
// array to store the answer row and column
|
||||
int ans[] = { -1, -1 };
|
||||
int[] ans = { -1, -1 };
|
||||
if (row < 0 || col >= arr[row].length) {
|
||||
return ans;
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class SaddlebackSearch {
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int arr[][];
|
||||
int[][] arr;
|
||||
int i, j, rows = sc.nextInt(), col = sc.nextInt();
|
||||
arr = new int[rows][col];
|
||||
for (i = 0; i < rows; i++) {
|
||||
@ -64,7 +64,7 @@ public class SaddlebackSearch {
|
||||
}
|
||||
int ele = sc.nextInt();
|
||||
// we start from bottom left corner
|
||||
int ans[] = find(arr, rows - 1, 0, ele);
|
||||
int[] ans = find(arr, rows - 1, 0, ele);
|
||||
System.out.println(ans[0] + " " + ans[1]);
|
||||
sc.close();
|
||||
}
|
||||
|
Reference in New Issue
Block a user