Tag Archives: first occurrence

Search first occurrence of a duplicated element in a sorted array

Given an array of integer with duplicated elements. Find the first occurrence of a given number in the array. For example: A = [1, 1, 1, 2, 2, 3, 3, 3, 4]. So, first occurrence of 2 is in index 3, first occurrence of 4 is in index 8. The problem can be solved efficiently […]