# 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; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up