Leetcode 1221 Solution
This article provides solution to leetcode question 1221 (element-appearing-more-than-25-in-sorted-array)
Access this page by simply typing in "lcs 1221" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array
Solution
class Solution:
def findSpecialInteger(self, arr: List[int]) -> int:
last_num = None
last_num_cnt = 0
for num in arr:
if last_num != num:
last_num = num
last_num_cnt = 1
else:
last_num_cnt += 1
if last_num_cnt > len(arr) // 4:
return last_num