Search
⌘K

Leetcode 1915. Number of Wonderful Substrings

Count the number of non-empty substrings (in a string of letters 'a'–'j') whose character counts have at most one odd frequency. Core idea: track a 10-bit parity mask for prefix counts and count pairs of prefixes with equal masks (all even) or masks differing by one bit (one odd) to obtain an O(n) solution.


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.