If you don't bang out the right answers to those off the top of your head, all the programming interviews are going to be painful.
If you don't bang out the right answers to those off the top of your head, all the programming interviews are going to be painful.
The employers need metrics, fairly standard ones, to filter out unqualified employees and these sorts of simple algorithms and data structures are the least bad ones.
Where I complain is when the interviewer explains "to solve this problem, you need to think of them as virtual ants that can pass through each other" (yes this was actually what my interviewer said for https://leetcode.com/problems/last-moment-before-all-ants-fa...).
I'm guessing some do, the kinds of employers who attract a lot of applicants who misrepresent their education and experience.
I have never been asked to write code in a job interview. I guess I've been fortunate to find employers who look at my resume and talk to me as a person not a metric.
These are a given. You should know these.
When I said I cannot memorize solutions, I refer to memorizing solutions to specific Leetcode problems. Doing that for 1-2 problems per main area is doable, but anything more than that is quite hard.