Leetcode 1510 Solution
This article provides solution to leetcode question 1510 (find-lucky-integer-in-an-array)
Access this page by simply typing in "lcs 1510" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/find-lucky-integer-in-an-array
Solution
class Solution:
def findLucky(self, arr: List[int]) -> int:
m = collections.defaultdict(int)
for v in arr:
m[v] += 1
for k, v in sorted(m.items(), reverse=True):
if k == v:
return v
return -1