Skip to content
LC-1394 Easy LeetCode

1394. Find Lucky Integer in an Array

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 69% Topics: Array, Hash Table, Counting
View full problem on LeetCode

Reading material

Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(n)

import collections


class Solution(object):
    def findLucky(self, arr):
        """
        :type arr: List[int]
        :rtype: int
        """
        count = collections.Counter(arr)
        result = -1
        for k, v in count.iteritems():
            if k == v:
                result = max(result, k)
        return result

Solution from kamyu104/LeetCode-Solutions · MIT