2 ms·
Problem is not that all of us are capable to come up with good solutions at time constrained conditions. For some (including myself) sleep over the problem is r
by c-smile 4y ago
Problem is not that all of us are capable to come up with good solutions at time constrained conditions. For some (including myself) sleep over the problem is required. Experience helps in some cases to answer immediately but not always.
Like for the mentioned task: "returns a boolean in response to the question of whether sequence A is a sub-sequence of sequence B."
I recall immediately that there is a well known algorithm for that (due to experience). What's the name and its idea - out of memory... Myers Diff, Boyer–Moore, something like that.
Yes, we can start immediately writing brute force solution and analyze it. And probably that's the way of how to answer interview questions: write simplest solution and come up with optimizations.
In any case coding at interview is far, far away from real coding.