Element Appearing More Than 25% In Sorted Array
Here’s a way to approach the problem by iterating through the sorted array:


The solution iterates through the array, keeping track of the count of consecutive identical integers. When the count of a particular integer is greater than 25% of the array’s length, that integer is returned. Since the array is sorted in nondecreasing order, we can simply compare each element with the previous one to decide whether to increment the count or reset it. The solution takes care of the case where the last integer has a count greater than 25% as well.