Skip to content

Commit 2b560ef

Browse files
Create Equality Explanation.txt
1 parent 89a2b1c commit 2b560ef

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
We want the minimum frequency.
2+
3+
-----------------
4+
5+
#include <cstdio>
6+
#include <string>
7+
#include <algorithm>
8+
#include <vector>
9+
#include <iostream>
10+
11+
#define all(v) (v).begin(), (v).end()
12+
using namespace std;
13+
14+
int main()
15+
{
16+
int length, no_of_letters;
17+
string S;
18+
cin >> length >> no_of_letters >> S;
19+
20+
vector <int> frequency(no_of_letters, 0);
21+
for(int i = 0; i < S.size(); i++)
22+
frequency[S[i] - 'A']++;
23+
24+
int minimum_frequency = length + 1;
25+
for(int i = 0; i < no_of_letters; i++)
26+
minimum_frequency = min(minimum_frequency, frequency[i]);
27+
28+
int answer = minimum_frequency*no_of_letters;
29+
cout << answer;
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)