You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given an array of integers `arr`, a lucky integer is an integer which has a frequency in the array equal to its value.
8
+
9
+
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**.
10
+
11
+
## Example:
12
+
13
+
```
14
+
Input: arr = [2,2,3,4]
15
+
Output: 2
16
+
Explanation: The only lucky number in the array is 2 because frequency[2] == 2.
17
+
```
18
+
```
19
+
Input: arr = [1,2,2,3,3,3]
20
+
Output: 3
21
+
Explanation: 1, 2 and 3 are all lucky numbers, return the largest of them.
22
+
```
23
+
```
24
+
Input: arr = [2,2,2,3,3]
25
+
Output: -1
26
+
Explanation: There are no lucky numbers in the array.
0 commit comments