Search
⌘K

Leetcode 1542. Find Longest Awesome Substring

Find the length of the longest substring of a digit string that can be rearranged into a palindrome (i.e., at most one digit has an odd count). Solve by tracking prefix parity with a 10-bit mask and, for each position, using the earliest index seen for the same mask or any mask that differs by one bit to compute the maximum length efficiently.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.