2 ms·
I wouldn't actually class this as a brain-teaser. It is a non-trivial[1] problem that doesn't require an "aha!" moment to get right. It is amenable to multiple
by randomswede 5y ago
I wouldn't actually class this as a brain-teaser. It is a non-trivial[1] problem that doesn't require an "aha!" moment to get right. It is amenable to multiple ways of reaching a correct solution. It has interesting follow-up questions. It also stands a minimal chance to actually discover (some) of the way a candidate thinks. It is also implementing the VM for a Turing-complete computational model.
It may also be that anything work-related is actually too long to fit into a limited interview time.
Now, a trivial, brain-teaser, question would be "you have an NxM matrix, and you can either go left or up. How many paths are there from the lower left, to the upper-right corner?"
I consider it a brain-teaser because if you write code that contains any matrix manipulation or searching, you have basically failed. There is a closed-form expression for the number, so...
[1] By "non-trivial", I basically mean that there are multiple correct solutions.