java.lang.Object
g2401_2500.s2414_length_of_the_longest_alphabetical_continuous_substring.Solution

public class Solution extends Object
2414 - Length of the Longest Alphabetical Continuous Substring.<p>Medium</p> <p>An <strong>alphabetical continuous string</strong> is a string consisting of consecutive letters in the alphabet. In other words, it is any substring of the string <code>&quot;abcdefghijklmnopqrstuvwxyz&quot;</code>.</p> <ul> <li>For example, <code>&quot;abc&quot;</code> is an alphabetical continuous string, while <code>&quot;acb&quot;</code> and <code>&quot;za&quot;</code> are not.</li> </ul> <p>Given a string <code>s</code> consisting of lowercase letters only, return the <em>length of the <strong>longest</strong> alphabetical continuous substring.</em></p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;abacaba&rdquo;</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> There are 4 distinct continuous substrings: &ldquo;a&rdquo;, &ldquo;b&rdquo;, &ldquo;c&rdquo; and &ldquo;ab&rdquo;.</p> <p>&ldquo;ab&rdquo; is the longest continuous substring.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;abcde&rdquo;</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> &ldquo;abcde&rdquo; is the longest continuous substring.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 10<sup>5</sup></code></li> <li><code>s</code> consists of only English lowercase letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • longestContinuousSubstring

      public int longestContinuousSubstring(String s)