Skip to content

Commit 25aa408

Browse files
authored
Create 1394. Find Lucky Integer in an Array (#833)
2 parents 978641a + a3e927f commit 25aa408

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

1394. Find Lucky Integer in an Array

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Solution {
2+
public:
3+
int findLucky(vector<int>& arr) {
4+
unordered_map<int,int> map1;
5+
6+
for(auto it : arr)
7+
{
8+
map1[it]++;
9+
}
10+
11+
12+
int count =-1;
13+
14+
for(auto x : map1)
15+
{
16+
if(x.first == x.second)
17+
{
18+
count = max(count,x.first);
19+
20+
}
21+
}
22+
23+
return count;
24+
25+
26+
}
27+
};

0 commit comments

Comments
 (0)