Find Longest Awesome Substring

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.

Return the length of the maximum length awesome substring of s.

Example 1
Inputs = "3242415"
Output5
"24241" is the longest awesome substring, and it can be rearranged into the palindrome "24142" with some swaps.
Example 2
Inputs = "12345678"
Output1
No substring longer than one character can be rearranged into a palindrome, so the maximum length is 1.

Constraints

  • 1 <= s.length <= 10^5
  • s consists only of digits.

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate