We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89a2b1c commit 2b560efCopy full SHA for 2b560ef
Contests/Div 2 508/Explanation/Equality Explanation.txt
@@ -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