leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2412.cpp (500B)
0 static const auto _ = []() {
1 ios_base::sync_with_stdio(false);
2 cin.tie(NULL);
3 cout.tie(NULL);
4 return NULL;
5 }();
7 class Solution {
8 public:
9 int longestContinuousSubstring(const string &s) const {
10 int res = 0, crnt = 1;
11 for (int i = 1; i < size(s); i++) {
12 if (s[i] - s[i - 1] == 1)
13 crnt++;
14 else {
15 res = max(res, crnt);
16 crnt = 1;
17 }
18 }
19 return max(res, crnt);
20 }
21 };