1394. Find Lucky Integer in an Array
https://leetcode.com/problems/find-lucky-integer-in-an-array/
Given an array of integers arr
, a lucky integer is an integer which has a frequency in the array equal to its value.
Return a lucky integer in the array. If there are multiple lucky integers return the largest of them. If there is no lucky integer return -1.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= arr.length <= 500
1 <= arr[i] <= 500
找数组中出现次数和值相等中最大的数,没有次数和值相等的元素时返回-1。依题意统计频率后找max。
PreviousPairs of Songs With Total Durations Divisible by 60Next1497. Check If Array Pairs Are Divisible by k
Last updated
Was this helpful?