Skip to content

Commit bc4768e

Browse files
committed
2414. Length of the Longest Alphabetical Continuous Substring: RETRY
1 parent c08981c commit bc4768e

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

src/solution/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,3 +1830,4 @@ mod s2410_maximum_matching_of_players_with_trainers;
18301830
mod s2411_smallest_subarrays_with_maximum_bitwise_or;
18311831
mod s2412_minimum_money_required_before_transactions;
18321832
mod s2413_smallest_even_multiple;
1833+
mod s2414_length_of_the_longest_alphabetical_continuous_substring;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* [2414] Length of the Longest Alphabetical Continuous Substring
3+
*
4+
* An alphabetical continuous string is a string consisting of consecutive letters in the alphabet. In other words, it is any substring of the string "abcdefghijklmnopqrstuvwxyz".
5+
*
6+
* For example, "abc" is an alphabetical continuous string, while "acb" and "za" are not.
7+
*
8+
* Given a string s consisting of lowercase letters only, return the length of the longest alphabetical continuous substring.
9+
*
10+
* Example 1:
11+
*
12+
* Input: s = "abacaba"
13+
* Output: 2
14+
* Explanation: There are 4 distinct continuous substrings: "a", "b", "c" and "ab".
15+
* "ab" is the longest continuous substring.
16+
*
17+
* Example 2:
18+
*
19+
* Input: s = "abcde"
20+
* Output: 5
21+
* Explanation: "abcde" is the longest continuous substring.
22+
*
23+
*
24+
* Constraints:
25+
*
26+
* 1 <= s.length <= 10^5
27+
* s consists of only English lowercase letters.
28+
*
29+
*/
30+
pub struct Solution {}
31+
32+
// problem: https://leetcode.com/problems/length-of-the-longest-alphabetical-continuous-substring/
33+
// discuss: https://leetcode.com/problems/length-of-the-longest-alphabetical-continuous-substring/discuss/?currentPage=1&orderBy=most_votes&query=
34+
35+
// submission codes start here
36+
37+
impl Solution {
38+
pub fn longest_continuous_substring(s: String) -> i32 {
39+
0
40+
}
41+
}
42+
43+
// submission codes end
44+
45+
#[cfg(test)]
46+
mod tests {
47+
use super::*;
48+
49+
#[test]
50+
#[ignore]
51+
fn test_2414_example_1() {
52+
let s = "abacaba".to_string();
53+
54+
let result = 2;
55+
56+
assert_eq!(Solution::longest_continuous_substring(s), result);
57+
}
58+
59+
#[test]
60+
#[ignore]
61+
fn test_2414_example_2() {
62+
let s = "abcde".to_string();
63+
64+
let result = 5;
65+
66+
assert_eq!(Solution::longest_continuous_substring(s), result);
67+
}
68+
}

0 commit comments

Comments
 (0)