LeetCode 1394, Easy. Topics: Array, Hash Table, Counting. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 27 parametrized pytest cases, and a playground notebook:
Problem
Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.
Return the largest lucky integer in the array. If there is no lucky integer return -1.
Examples
Constraints
- 1 <= arr.length <= 500
- 1 <= arr[i] <= 500
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026