> * Input: arr[] = {2, 5, 3, 5, 4, 4, 2, 3}, x = 3, y = 2
> * Output: Minimum distance between 3 and 2 is 1.
**METHOD 1 (Simple)**
METHOD 1 (Simple)
--------------------------
Use two loops: The outer loop picks all the elements of arr[] one by one. The inner loop picks all the elements after the element picked by outer loop. If the elements picked by outer and inner loops have same values as x or y then if needed update the minimum distance calculated so far.
> * Input: {0, 1, 2, 3, 4, 5, 6, 7, 10}, n = 9, m = 11
> * Output: `8`
**METHOD 1 (Use Binary Search)**
METHOD 1 (Use Binary Search)
--------------------------
`For i = 0 to m-1`, do binary search for i in the array. If i is not present in the array then `return i`.
Algorithm Complexity
--------------------------
**Algorithm Complexity**
| Complexity | Notation |
| ----------------- |:------------:|
| `Time Complexity` | `O(m log n)` |
**METHOD 2 (Linear Search)**
METHOD 2 (Linear Search)
--------------------------
If `arr[0] is not 0`, `return 0`. Otherwise traverse the input array starting from index 0, and for each pair of elements a[i] and a[i+1], find the difference between them. if the difference is greater than 1 then `a[i] + 1` is the missing number.
Algorithm Complexity
--------------------------
**Algorithm Complexity**
| Complexity | Notation |
| ----------------- |:------------:|
| `Time Complexity` | `O(n)` |
**METHOD 3 (Use Modified Binary Search)**
METHOD 3 (Use Modified Binary Search)
--------------------------
In the standard Binary Search process, the element to be searched is compared with the middle element and on the basis of comparison result, we decide whether to search is over or to go to left half or right half.
In this method, we modify the standard Binary Search algorithm to compare the middle element with its index and make decision on the basis of this comparison.
@ -56,8 +56,7 @@ In this method, we modify the standard Binary Search algorithm to compare the mi
`Note:This method doesn’t work if there are duplicate elements in the array.`