题解 | 最大字母矩阵
最大字母矩阵
https://www.nowcoder.com/practice/270ff3b150704f8795fd4a944a7e043a
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; } };