Earlier quoted context omitted.
> If you didn't know how to solve it before the interview started, you aren't going to figure out anything other than a brute force solution in 45 minutes. I'd never heard this problem before and it took a few seconds to think of something better than brute force. Many colleagues I've worked with would too, and could probably improve on their first non-brute-force idea over the span of 25 minutes.
Have you studied cracking the coding interview before? If so, then I think you’ve probably seen similar problems. I find these problems very annoying and I code a lot of clever algorithms in my research. But none of it is have the strong scanning variety, I mean, except lexing in a compiler. And that’s how I would solve this problem in any case: I would just construct a scanner for D that would simply add to the stat…
My claim was a very weak one, too. It was that somebody who never heard the problem before can get better than the brute force solution in 45 minutes. As m0zg intended it, that means better than 2^n*|D|, which is easily true. As I intended it, that people could do better than the "greedy" algorithm in 45 minutes, well, my image of a canonical developer is going to get the greedy algorithm right away, and then have 45 minutes to improve on it. And, I think they'd be able to accomplish that.