标签:class substring max 字符 else tor logs problems ||
详见:https://leetcode.com/problems/unique-substrings-in-wraparound-string/description/
C++:
class Solution {
public:
int findSubstringInWraproundString(string p)
{
vector<int> cnt(26, 0);
int len = 0;
for (int i = 0; i < p.size(); ++i)
{
if (i > 0 && (p[i] == p[i - 1] + 1 || p[i - 1] - p[i] == 25))
{
++len;
}
else
{
len = 1;
}
cnt[p[i] - ‘a‘] = max(cnt[p[i] - ‘a‘], len);
}
return accumulate(cnt.begin(), cnt.end(), 0);
}
};
参考:https://www.cnblogs.com/grandyang/p/6143071.html
467 Unique Substrings in Wraparound String 封装字符串中的独特子字符串
标签:class substring max 字符 else tor logs problems ||
原文地址:https://www.cnblogs.com/xidian2014/p/8902548.html