That’s quite possible. And probably because you’d worked on something where this applied before.
Also exactly the reason I posted my message since that doesn’t apply for everyone. People that already know may be blind to that though.
Also exactly the reason I posted my message since that doesn’t apply for everyone. People that already know may be blind to that though.
The crux here is to notice that the order of the letters in the word we're given does not matter (because of the "any permutation" part). So it must be a matter of counting the letters. GlennS got it right: https://news.ycombinator.com/item?id=28550511
The second insight was that only the parity of occurrence mattered. Having 2 or 4 or 6 times the same letter is the same as not having the letter at all, so I only have to retain "zero" or "one" for each letter. Sets are perfect for this: "zero" means "not there", "one" means it's there, and at the end I can tolerate at most one odd letter.