#1542
Find Longest Awesome Substring
candidate master · 1515 · lc hard +32 · verified · 46.6% accepted · 890 likes · top 31%
Description
Given a digit string s, an awesome substring is one that can be rearranged into a palindrome. Return the length of the longest such awesome substring.
Example 1:
Input: s = "3242415"
Output: 5
Explanation: "24241" is the longest awesome substring, we can form the palindrome "24142" with some swaps.
Example 2:
Input: s = "12345678"
Output: 1
Example 3:
Input: s = "213123"
Output: 6
Explanation: "213123" is the longest awesome substring, we can form the palindrome "231132" with some swaps.
Code
1
2
3