#1287

Element Appearing More Than 25% In Sorted Array

pupil · 365 · lc easy +23 · verified · 61.1% accepted · 1,775 likes · top 61%

Description

A sorted (non-decreasing) integer array contains exactly one element that appears in more than 25% of its positions. Find and return that element.

Example 1:

Input: arr = [1,2,2,6,6,6,6,7,10]
Output: 6

Example 2:

Input: arr = [1,1]
Output: 1

Code

1
2
3