Comment by shmerl
19 hours ago
More exactly, you can't invent algorithms on a spot which took who knows how many years for others to invent. I.e. the question ends up being more if you know about a specific algorithm, which results in "invent it if you don't know about it". It's absolutely silly to test for ability to invent one on the spot, so it's a pretty pointless interview question really.
You can for simple algorithms. It's just really easy for interviewers to overestimate how simple an algorithm is when they have been told the answer.
Yeah, that's exactly the point. These kind of algorithms are far from easy to invent even if they look simple once they are known.
I hate when it asks for a memorized specific problem, but most of the hard ones I found needs a clever twist of a well-known algorithm, and I still struggle at that too for hard LC.