Monthly Essay: Cracking the Coding Interview vs Elements of Programming Interviews

Photo by Lewis Kang'ethe Ngugi on Unsplash

The interview process and more

Both books start with the main things you should take into account prior to going straight forward to the technical stuff. That is, what does a technical interview involve? What do we need to know?

  • Analytical and coding skills.
  • Technical knowledge and CS fundamentals.
  • Experience, and communication skills.

Main things to remember

Get the right experience:

  • Take the big project classes.
  • Get an internship.
  • Start something, build a project.
  • Shift work responsibilities more towards coding.
  • Use your nights and weekends.
  • A résumé needs to address HR staff
  • The points that differentiate you from everyone else, the most important points, should go first.
  • Had friends review your resume.
  • Practice with Mock interviews.

Complexity — Big O

Understanding this topic is a must. Even if you have already studied it before, my advice is to learn about it again and go through different exercises. So, which book should you use to study this concept?

  • Space complexity, how is memory used on each call?
  • Drop the constants, if we have a for loop going over a data set and performing an operation it would take O(N). Also if we have two non-nested for loops going over the same data set and performing an operation we would describe it as O(2N), and dropping constants O(N).
  • Drop the non-dominant terms, for example, O(N + log N) becomes O(N). This is because of the rate at which the operations grow, O(N) grows way faster than O(log N).
  • Multipart algorithms: If your algorithm performs a task, finishes, and then does another, you add the runtimes (like non-nested for loops). If your algorithm performs a task for each time you do something else, then you multiply the runtimes (like 2 nested for loops).
  • Amortized time, allows us to describe that although a worst-case happens once in a while, once it happens it will not happen again for so long that the cost is amortized.

Data structures, Algorithms, and Solving Principles

I have reviewed some data structures in past blog posts, nevertheless, I would like to give you my main takeaways on this. My recommendation is, start going through these topics on the Cracking the Coding Interview book, in parallel consult other resources to have a better idea while you study. Then, you can practice them in that same book or go through very interesting problems in the EPI books, where you will also find a refresher to solidify your knowledge. Here I share a summary that you will found in the EPI book.

  1. Listen: Pay close attention to details while the problem is being exposed and save mental notes on the key consideration. Those key aspects might be necessary to take into account to construct an optimal algorithm.
  2. Example: As mentioned before examples are of great help, nonetheless, you must debug your example to consider special cases and different sizes of input.
  3. Brute force: Work to get a brute-force solution, do not worry about efficiency yet. Do not code yet, but find it as soon as possible so you can also start thinking about improvements.
  4. Optimize: Go through your brute-force solution using the BUD optimization (bottlenecks, unnecessary work, duplicate work). That is, look for unused info. Solve manually by using an example and then reverse engineer your thought process. Solve it incorrectly and think about why the algorithm fails. Make time vs space tradeoffs.
  5. Walkthrough: If you get an optimal solution go through your approach in detail, making sure that you have understood every part before start coding.
  6. Implement: Modularize your solution and write clean code.
  7. Test: Walk through your code as you would in a code review, check unusual code, hot spots, create small test cases, review special cases, and edge cases.

More important topics

As explained above depending on your experience and the job, your interview might have more material on some topics than on others. Some important topics to review that are present in these books are:

  • Object-oriented design, design patterns. Other programming paradigms.
  • System design, and scalability (find good design problems in the EPI book).
  • Testing, types of testing, styles of programming (TDD, BDD).
  • Language questions (if you know you will be interviewed for a specific language). Here the Elements of Programming Interviews book can help a lot in an included section design for this (remember you can find a book for Java, C++, or Python).
  • Common tools: Databases, version control systems, networking, etc.

Conclusion

Both books are amazing and brilliant resources to prepare you for your coding interview, it is up to you to decide whether go for one or the other (or the two). If you ask me, go for the two and do them in the order I told you above, if you only want to go for one book:

  • If you need a big refresher on the topics before beginning working on problems go for Cracking the Coding Interview, if you cannot remember enough or if you know just a little of complexity and big O, go again for the same book.
  • If you want to go more specific over a language (Java, C++, or Python) and you already have experience with the concepts but need to work on problems go for the EPI.
Photo by Pete Pedroza on Unsplash

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eduardo Ahumada

Eduardo Ahumada

8 Followers

Engineer looking to help and contribute. Learning about Software development and Computer Science.