1394. Find Lucky Integer in an Array

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1394

class Solution:
    def findLucky(self, arr: List[int]) -> int:
        cnt = Counter(arr)
        res = -1
        for x, v in cnt.items():
            if x == v and res < x:
                res = x
        return res