(int arr[], int n, int x, int k)
| 3 | |
| 4 | // Function for finding maximum and value pair |
| 5 | public static int search (int arr[], int n, int x, int k) { |
| 6 | //Complete the function |
| 7 | |
| 8 | int index=0; |
| 9 | |
| 10 | while(index<n) |
| 11 | { |
| 12 | if(arr[index]==x) return index; |
| 13 | |
| 14 | int steps = Math.abs(arr[index]-x)/k; |
| 15 | |
| 16 | index= index + Math.max(1,steps); |
| 17 | } |
| 18 | |
| 19 | return -1; |
| 20 | } |
| 21 | } |
nothing calls this directly
no outgoing calls
no test coverage detected