-
Floor in a sorted array
```java int floorSearch(int arr[], int low, int high, int x) { if (low > high) { return -1; }
-
Find the odd appearing element in O(Log n) time
```java void search(int arr[], int low, int high) { if (low > high) { return; } if (low == high) { System.out.printf(“The required element is %d “, arr[low]); return; }
-
Find a pair with the given difference
```java boolean findPair(int arr[], int n) { int size = arr.length;
-
Check if array elements are consecutive
```java boolean areConsecutive(int arr[], int n) { if (n < 1) { return false; }
-
Ceiling in a sorted array
```java int ceilSearch(int arr[], int low, int high, int x) { int mid;
-
战国策
聂政刺韩傀
荆轲刺秦王
豫让刺赵襄子
狐假虎威
鹬蚌相争
画蛇添足
亡羊补牢
-
Union and Intersection of two sorted arrays
```java int printUnion(int arr1[], int arr2[], int m, int n) { int i = 0, j = 0; while (i < m && j < n) { if (arr1[i] < arr2[j]) { System.out.print(arr1[i++] + “ “); } else if (arr2[j] < arr1[i]) { System.out.print(arr2[j++] + “ “); } else { System.out.print(arr2[j] + “ “); i++; j++; } }
-
宋高僧传-唐朗州药山惟俨
-
Find the minimum distance between two numbers
```java void segregateEvenOdd(int arr[]) { int left = 0, right = arr.length - 1; while (left < right) { while (arr[left] % 2 == 0 && left < right) { left++; } while (arr[right] % 2 == 1 && left < right) { right–; } if (left < right) { int temp = arr[left]; arr[left] = arr[right]; arr[right] = temp; left++; right–; } } }
-
Replace every element with the greatest element on right side
```java void nextGreatest(int arr[]) { int size = arr.length;