1542. Find Longest Awesome Substring Hard

@problem@discussion
#Hash Table#String#Bit Manipulation



1/**
2 * [1542] Find Longest Awesome Substring
3 *
4 * You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome.
5 * Return the length of the maximum length awesome substring of s.
6 *  
7 * Example 1:
8 * 
9 * Input: s = "3242415"
10 * Output: 5
11 * Explanation: "24241" is the longest awesome substring, we can form the palindrome "24142" with some swaps.
12 * 
13 * Example 2:
14 * 
15 * Input: s = "12345678"
16 * Output: 1
17 * 
18 * Example 3:
19 * 
20 * Input: s = "213123"
21 * Output: 6
22 * Explanation: "213123" is the longest awesome substring, we can form the palindrome "231132" with some swaps.
23 * 
24 *  
25 * Constraints:
26 * 
27 * 	1 <= s.length <= 10^5
28 * 	s consists only of digits.
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/find-longest-awesome-substring/
34// discuss: https://leetcode.com/problems/find-longest-awesome-substring/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn longest_awesome(s: String) -> i32 {
40        0
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_1542() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.