Decent examples. I'd like to toss another in that, years ago, a colleague gave a candidate. He thought of the question that morning in the shower.
Morse Code. All letters are combinations of one or more dashes and/or dots. Here is a sentence of Morse Code where the spaces are stripped. Decode it to get the original ASCII sentence.
He gave it and failed the candidate. Sounding like an interesting problem, some of us in the office tried it. Turns out that it is a very hard problem. You have to make a tree of possibilities and it is easy to accidentally make your solution O(n!).
Moral of the story is never give out a coding question that have not personally solved. Second moral: be open to out of the box solutions.
Morse Code. All letters are combinations of one or more dashes and/or dots. Here is a sentence of Morse Code where the spaces are stripped. Decode it to get the original ASCII sentence.
He gave it and failed the candidate. Sounding like an interesting problem, some of us in the office tried it. Turns out that it is a very hard problem. You have to make a tree of possibilities and it is easy to accidentally make your solution O(n!).
Moral of the story is never give out a coding question that have not personally solved. Second moral: be open to out of the box solutions.