Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b94acea

Browse files
Create Code : Maximum Frequency Number
1 parent 4d72192 commit b94acea

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<unordered_map>
2+
int highestFrequency(int arr[], int n) {
3+
unordered_map<int,int> ourmap;
4+
int maxF=0;
5+
for(int i=0;i<n;i++){
6+
ourmap[arr[i]]++;
7+
maxF=max(maxF,ourmap[arr[i]]);
8+
}
9+
int maxFelement;
10+
for(int i=0;i<n;i++){
11+
if(ourmap[arr[i]]==maxF){
12+
maxFelement=arr[i];
13+
break;
14+
}
15+
}
16+
return maxFelement;
17+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /