-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3601.cpp
57 lines (49 loc) · 848 Bytes
/
3601.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <string>
#include <map>
#include <unordered_map>
using namespace std;
class Solution
{
public:
Solution(string& s): str_(s) {}
void Init()
{
if (str_.size() == 0)
return;
for (size_t i = 0; i != str_.size(); ++i)
{
for (size_t j = 1; j <= str_.size()-i; ++j)
{
occurences_[str_.substr(i, i+j)]++;
}
}
}
int MaxOcurrence()
{
int ret = 0;
for (auto iter = occurences_.begin();
iter != occurences_.end(); ++iter)
{
if (iter->second > ret)
ret = iter->second;
}
return ret;
}
private:
string& str_;
unordered_map<string, int> occurences_;
};
//
int Frequency(const string& str)
{
}
int main()
{
string input;
cin >> input;
Solution so(input);
so.Init();
cout << so.MaxOcurrence();
return 0;
}