Find Longest Awesome Substring
A hard-tier problem at 45% community acceptance, tagged with Hash Table, String, Bit Manipulation. Reported in interviews at Directi and 0 others.
Find Longest Awesome Substring is a hard problem that asks you to locate the longest substring where every digit 0-9 appears an even number of times (including zero times). It's a bitmask problem disguised as a string question, and it trips up candidates because the constraint is non-obvious at first. Directi asks this. The 45% acceptance rate tells you most people either miss the bit manipulation angle or implement a brute force that times out. If this lands in your OA and you blank on the bitmask state-tracking approach, StealthCoder surfaces the working solution in seconds, invisible to the proctor.
Companies that ask "Find Longest Awesome Substring"
Find Longest Awesome Substring is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.
Get StealthCoderThe trick is to treat digit parity as a bitmask: each of the 10 digits gets one bit, and you track whether that digit has appeared an odd or even number of times. A substring from index i to j has all even-count digits if and only if the bitmask state at j XOR the bitmask state at i-1 equals zero. That means you store the first occurrence of each bitmask value in a hash table, then when you see a repeated mask, the substring between those two indices has all even counts. The common failure is not recognizing this is a bitmask + hash table problem, or trying to track actual counts per digit instead of parity. Most people attempt nested loops or a sliding window that doesn't exist here. Hash Table and Bit Manipulation from the topics list are both load-bearing. StealthCoder helps when you're minutes into writing an O(n2) solution and the time limit cuts you off.
Pattern tags
You know the problem.
Make sure you actually pass it.
Find Longest Awesome Substring recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find Longest Awesome Substring interview FAQ
Is this really asking for all digits 0-9 to appear exactly once?+
No. It wants even counts, meaning 0, 2, 4, etc. occurrences per digit. A substring with no digit appearing at all is valid (all digits have count 0, which is even). That's the gotcha most people miss on first read.
Why is bitmask faster than a frequency map?+
Bitmask stores only parity (10 bits total, fits in an int), not actual counts. You can compare two masks with XOR in O(1). A frequency map requires hashing and comparison of whole dictionaries. Bitmask + hash table scales to O(n) easily.
How do you know which substrings to check?+
Store the first occurrence of each bitmask state. When you see a bitmask again later, the substring between those two positions has all even-digit counts. This is why hash table is in the topics. You never check all O(n2) pairs.
Do I have to track all 1024 possible bitmask states?+
No. You only record bitmask states you actually encounter while scanning the string. Most strings won't hit all 1024 masks. You start with mask 0 at index -1 to handle substrings starting at index 0.
Is this still asked after the problem went public?+
Directi has reported this problem. At 45% acceptance on a hard problem, it's selective but still live. The bitmask + hash table combo isn't taught in most bootcamps, so the problem stays hard even with public discussion.
Want the actual problem statement? View "Find Longest Awesome Substring" on LeetCode →