Zepruv › Coding problems

Find Longest Awesome Substring

Hard · Hash Table, String, Bit Manipulation

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

Input: s = "3242415"
Output: 5

"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

"213123" is the longest awesome substring, we can form the palindrome "231132" with some swaps.

Constraints

Starter code (python)

class Solution(object):
    def longestAwesome(self, s):
        """
        :type s: str
        :rtype: int
        """
        

Related problems

Previous: Find Kth Bit in Nth Binary String · Next: Minimum Cost to Cut a Stick · All problems

Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.