2412.cpp (500B)
1 static const auto _ = []() { 2 ios_base::sync_with_stdio(false); 3 cin.tie(NULL); 4 cout.tie(NULL); 5 return NULL; 6 }(); 7 8 class Solution { 9 public: 10 int longestContinuousSubstring(const string &s) const { 11 int res = 0, crnt = 1; 12 for (int i = 1; i < size(s); i++) { 13 if (s[i] - s[i - 1] == 1) 14 crnt++; 15 else { 16 res = max(res, crnt); 17 crnt = 1; 18 } 19 } 20 return max(res, crnt); 21 } 22 };