We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
字母序连续字符串是由字母表中连续字母组成的字符串。换句话说,字符串 "abcdefghijklmnopqrstuvwxyz" 的任意子字符串都是 字母序连续字符串 。
例如,"abc" 是一个字母序连续字符串,而 "acb" 和 "za" 不是。 给你一个仅由小写英文字母组成的字符串s,返回其 最长 的 字母序连续子字符串 的长度。
s
输入:s = "abacaba" 输出:2 解释:共有 4 个不同的字母序连续子字符串 "a"、"b"、"c" 和 "ab" 。 "ab" 是最长的字母序连续子字符串。
输入:s = "abcde" 输出:5 解释:"abcde" 是最长的字母序连续子字符串。
来源:力扣(LeetCode) 链接:https://leetcode.cn/problems/length-of-the-longest-alphabetical-continuous-substring 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
The text was updated successfully, but these errors were encountered:
class Solution { /** * @param String $s * @return Integer */ function longestContinuousSubstring($s) { $result = 1; $consequent[] = $s[$i]; for ($i = 0; $i < strlen($s); $i++) { if (ord($consequent[count($consequent)-1]) + 1 === ord($s[$i])) { $consequent[] = $s[$i]; continue; } $result = count($consequent) > $result ? count($consequent) : $result; $consequent = []; $consequent[] = $s[$i]; } return count($consequent) > $result ? count($consequent) : $result; } }
Sorry, something went wrong.
No branches or pull requests
字母序连续字符串是由字母表中连续字母组成的字符串。换句话说,字符串 "abcdefghijklmnopqrstuvwxyz" 的任意子字符串都是 字母序连续字符串 。
例如,"abc" 是一个字母序连续字符串,而 "acb" 和 "za" 不是。
给你一个仅由小写英文字母组成的字符串
s
,返回其 最长 的 字母序连续子字符串 的长度。示例 1:
示例 2:
提示:
来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/length-of-the-longest-alphabetical-continuous-substring
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
The text was updated successfully, but these errors were encountered: