---
# System prepended metadata

title: 2414. Length of the Longest Alphabetical Continuous Substring
tags: [Leetcode, Two Pointers, Medium]

---

# 2414. Length of the Longest Alphabetical Continuous Substring
###### tags: `Leetcode` `Medium` `Two Pointers`
Link: https://leetcode.com/problems/length-of-the-longest-alphabetical-continuous-substring/description/
## 思路
双指针
## Code
```java=
class Solution {
    public int longestContinuousSubstring(String s) {
        int ans = 1;
        int j = 0;
        for(int i=1; i<s.length(); i++){
            if(s.charAt(i)-s.charAt(j)!=i-j) j=i;
            ans = Math.max(i-j+1, ans);
        }
        return ans;
    }
}
```