class AlphaMatrix {
public:
int findAlphaMatrix(vector<string> dic, int n) {
// write code here
int maxArea = 0;
for (int l = 0; l < 50; ++l) {
for (int r = l; r < 50; ++r) {
unordered_map<string, int> count;
for (const string& word : dic) {
if (r < word.size()) {
string sub = word.substr(l, r - l + 1);
count[sub]++;
}
}
for (const auto& [s, c] : count) {
int area = (r - l + 1) * c;
maxArea = max(maxArea, area);
}
}
}
return maxArea;
}
};

京公网安备 11010502036488号