Find Longest Awesome Substring

HardString

Description

Given a string s, return the length of the longest awesome substring of s. A string is awesome if it can be made palindromic by rearranging some (or none) of its characters.

Examples

Input:s = "3242415"
Output:5
Explanation:

24241 can become palindrome 24142.

Input:s = "a"
Output:0
Explanation:

Edge case with a single character.

Input:s = "213123"
Output:6
Explanation:

The entire string is awesome, so the answer is 6.

Constraints

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

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!