1763. Longest Nice Substring Easy
1/**
2 * [1763] Longest Nice Substring
3 *
4 * A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice because 'A' and 'a' appear, and 'B' and 'b' appear. However, "abA" is not because 'b' appears, but 'B' does not.
5 * Given a string s, return the longest substring of s that is nice. If there are multiple, return the substring of the earliest occurrence. If there are none, return an empty string.
6 *
7 * Example 1:
8 *
9 * Input: s = "YazaAay"
10 * Output: "aAa"
11 * Explanation: "aAa" is a nice string because 'A/a' is the only letter of the alphabet in s, and both 'A' and 'a' appear.
12 * "aAa" is the longest nice substring.
13 *
14 * Example 2:
15 *
16 * Input: s = "Bb"
17 * Output: "Bb"
18 * Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring.
19 *
20 * Example 3:
21 *
22 * Input: s = "c"
23 * Output: ""
24 * Explanation: There are no nice substrings.
25 *
26 *
27 * Constraints:
28 *
29 * 1 <= s.length <= 100
30 * s consists of uppercase and lowercase English letters.
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/longest-nice-substring/
36// discuss: https://leetcode.com/problems/longest-nice-substring/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn longest_nice_substring(s: String) -> String {
42 String::new()
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_1763() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.