Oftentimes when reading articles and discussions about preparing for tech interviews, I see that one of the most common tips given is to “grind Leetcode.” (And sometimes HackerRank or CTCI, too.) I don’t think this advice totally wrong, but if you want to truly prepare for interviews, grinding Leetcode isn’t the best way to do so.
Instead, the best strategy to prepare for tech interviews is to take the time and fully learn the fundamentals of computer science. Throwing yourself at Leetcode problems without understanding basic concepts is frustrating and unproductive. And memorizing the answers is not helpful at all—trust me.
To make an analogy, you shouldn’t simply memorize the answers to “2 plus 2” or “4 times 4” to pass an arithmetic test; you should understand the concepts of addition, subtraction, multiplication, and division before practicing with or “grinding” specific problem sets. Furthermore, if you encountered problems that build on your arithmetic skills, like algebra problems, you would be in a much better position to learn how solve them.
Similarly, if you don’t get the concept of trees, you won’t truly understand how pre-order, in-order, post-order, and level-order traversal algorithms work. You also won’t be able to apply this concept to interview problems whose solutions use tree data structures like binary search trees and tries.
How do I learn the fundamentals of CS?
If you’re a computer science major, you should’ve already taken some classes covering some CS fundamentals. As a computer science student at the University of Illinois at Urbana-Champaign, I had taken a lot of the courses that taught me those fundamentals that were helpful in tech interviews during my college career. Here are the ones that I found the most useful:
- Discrete Structures (CS 173): Introduction to the concepts of recursion and big-O notation.
- Data Structures (CS 225): Algorithms related to advanced data structures like trees and graphs. I found this course the most important one I’ve taken during my college career with regards to tech interviews.
- Computer Architecture (CS 233): Caching and low-level programming. I’ve encountered interview questions about these, but infrequently.
- System Programming (CS 241): Concurrency, Unix, and more low-level programming. Interview questions about these are somewhat common.
- Algorithms & Models of Computation (CS 374): Backtracing, recursion, dynamic programming. I found this course very useful, too.
I studied my ass off for all of these courses, and the effort paid off in better being able to answer tech interview problems and receiving internship and new grad offers from great tech companies.
What if I can’t take CS classes at school?
If you aren’t a computer science major or you don’t have access to these classes, you still have access to plenty of online resources. Here are some that I or others have recommended.
- Algorithms specialization on Coursera
- MIT 6.006 Lecture Videos
- UC Berkeley CS 61B Lecture Slides
- UIUC CS 374 Lecture Slides
- Bradfield School of Computer Science
These are also helpful to review before tech interviews, too.
I hope this short post helps those struggling to answer problems asked in interviews. The path toward acing tech interviews and securing your dream internship/job can seem arduous, but it’s an intellectually stimulating one that is worth embracing.
April 2018 update: For more tips for computer science students, join my mailing to receive the latest updates from my blog!