Why are data structures so important in interviews? by Steven Lacerda (Morgan Hill, CA)
When I first started out I didn’t understand why as a front-end developer I received so many questions regarding data structures. Now, after a few years of development experience I understand why. I have interviewed many different candidates myself, and the reason I now ask data structure questions is because they are the most difficult questions. And also, because it separates those that learned in bootcamp and didn’t bother learning computer science and those that learned computer science.
I remember receiving a question like, if I implemented a stack, how could I keep the min values in the stack. Well, naively, you can just say store the min in a variable, but then when you decide to pop the stack off and you pop off the min that was in your variable, you would no longer be able to retrieve the next min.
So, the solution was to make 2 stacks, one that holds the min and another that stores all the values. So, when you receive a new min, you just add to the min stack, and then when you pop off values, and one of those values is the min, you pop off the min stack, and then the next min is sitting under it, which is now your new min.
Well, describing that may be tedious to follow, but it was thought provoking, which is why challenging interview questions usually involve data structures, search algorithms, or dropping eggs from 10 story buildings (logic questions).
Anyhow, not sure if this helps anyone, but it was cathartic for me.
Solving a problem is as good as those sexual feelings…sometimes, okay, maybe not. Straight from Morgan Hill, CA. Good luck!