Searching for an element in array with successive elements atmost 1 distance apart
Given an array of integers where each element has a difference of atmost 1 with it’s neighbors, we need to find the given element. For example, consider the array [1, 2, 2, 1, 2, 3, 2, 1], and the element to be searched is 3, we need to return the index 5. This is just…