2020 第 14 周 LeetCode 记录

Yiran at 
1394. Find Lucky Integer in an Array 链接到标题 找幸运数字,可以维护一个数组,然后统计出现过的次数,也可以直接使用 collections.Counter 实现。class Solution(object): def findLucky(self, arr): """ :type arr: List[int] :rtype: int """ cnt = [0] * 501 for a in arr: cnt[a] += 1 for i in range(500, 0, -1): if cnt[i] == i: return i return -1 1395……