HTMLify

LeetCode - Element Appearing More Than 25% In Sorted Array - Python
Views: 10 | Author: abh
class Solution:
    def findSpecialInteger(self, arr: List[int]) -> int:
        l = len(arr)
        t = l / 4
        freq = {}
        for n in arr:
            if n not in freq.keys():
                freq[n] = 0
            freq[n] += 1
        for k in freq.keys():
            if freq[k] > t:
                return k

Comments