My Art to Studying (Algorithms and Data Structures)

I finally did it. I secured a software engineering position at Google. I put my nose to the grindstone for several months to make myself hirable. While I am quite happy with how my life turned out, this is the post I wish I could have read in college: the post that may have put me on a path to one of the “top-tier” software employers much sooner.

First, make sure that you are in the right mindset. There is a lot of negativity out there when it comes to algorithms in the tech interview1 2 3 4 5. I, too, learned to hate algorithms from reading Hacker News while I was an impressionable college student. It was a convenient mentality for me to adopt to make me feel easier about my algorithmic deficiencies and dismiss the topic. Now, I have learned to appreciate the beauty and elegance of algorithms. It helps that the jobs I now qualify for have a higher pay band.

Ignore the haters; embrace algorithmic thinking.

There are resources I did not/could not utilize 8 years ago. Now, there are so many resources available, just picking a starting point can be daunting: MOOCs, blog posts, books, talks, lectures, etc etc etc.

If you can code up a binary search, and if you are (still) looking for an auto-didactic path to algorithmic and data structural greatness, this post may be helpful to you. Even if I were in school today, I would adopt these strategies on top of my course load.

tl;dr Read Cracking the Coding Interview. Watch lectures. Practice. Read and emulate great coders and their code.

Some good lectures:

  • MIT - The amazing lectures I wish I had when I went into Computer Science.

  • Stanford - Poses simple, fascinating problems and builds up the complexity. Keeps the material fresh and interesting with real-world applications.

  • Princeton - Very rigorous explanations which are a little hard to follow. Save this one for last (if you do all three, which I recommend).

Some good practice sites:

Examples of great code:

Learning:

Cracking the Coding Interview gives the lay of the land as to what to expect in a coding interview. Read/Skim it so that you have a good idea what kind of material is covered and in what formats.

Interviews involve convincing the interviewer of your expertise of the subject matter. And by watching lecturers, you get to see some of the foremost experts demonstrate their expertise by teaching the subject. Video consumption has been extremely complementary to my lifestyle. You can watch the lectures while you commute (on your mobile device), while you eat, while you do chores, while you exercise, etc. I even gauge my understanding by being able to keep up with a lecture through the audio only, listening to the lecture like it were a podcast.

Practice:

My bread and butter of practice problems and explanations were LeetCode and CodeFights (now called CodeSignal). I would often find myself encountering a problem that I do not understand, and read the provided solution. I would eventually come across lectures that covered the techniques used in the solution, such as dynamic programming, and I would be able to focus on the lecture and use the lecture material to prepare my explanation for how I would solve the problem. Solving a previously unsolvable problem is extremely gratifying.

Emulate:

Perhaps the best way to learn to write elegant code is to read elegant code. There are many examples of elegant code, but the two collections that taught me the most were Norvig’s pytudes and Laaksonen’s Competitive Programmer’s Handbook.

Postscript:

This post focused on algorithms and data structures, specifically to succeed in coding interviews. This is only a tiny portion of computer engineering. I transfer a lot of these techniques to how I study practically any other subject:

  • Adopt the right mindset by finding motivation that is intrinsic to material you are trying to learn.

  • Find convenient media to consume lessons - YouTube has been a fantastic source of college lectures and other educational videos like Khan Academy.

  • Apply the new lessons - Solve a problem that requires the new material, re-derive the conclusions of the new material, successfully teach the material to someone else, etc.

  • Learn from others who are demonstrating the skills you are trying to learn.


Footnotes

  1. http://qr.ae/TUpbZ7 - I am a B.Tech computer science student. I’ve heard that data structures and algorithms are very important and are asked in every interview, but I have no interest in that topic. What other options do I have? 

  2. http://qr.ae/TU8cYb - “algorithms” and “data structures” are ways of giving you something to do when you don’t know how to do anything. Algorithms are for n00bs. (700 upvotes) 

  3. https://www.quora.com/Why-do-most-software-developers-suck-at-algorithm-type-interview-questions/answer/Moray-Taylor - those algo questions are only vaguely related to the actual job. If you think professional programming is about solving algorithm puzzles, you are in for a rude awakening. (2k upvotes) 

  4. https://www.quora.com/What-are-the-common-misconceptions-that-aspiring-programmers-have/answer/Moray-Taylor - Programming is about algorithms? [No,] programming is about building solutions, that’s it. (1.7k upvotes) 

  5. https://www.quora.com/Why-is-Introduction-to-Algorithms-a-must-read-for-becoming-a-better-programmer/answer/John-Byrd-2 - This was an answer extremely critical of learning algorithms that has since unfortunately been deleted 

comments powered by Disqus