Originally this message was a comment under a Clayton's Wong post:
https://leetcode.com/discuss/interview-experience/424540/google-l5-mtv-oct-2019-offer
which swiftly became hot in leetcode community recently.
This message contains my personal experience and beliefs that I'm applying to learn data structures
and algorithms in leetcode.com since I got a rejection from one of FANG after interviewing with them onsite.
I decided to repost it here so maybe someone can find it useful.
My background:
4.5 years of learning programming and working as fullstack software engineer, comming
from a completely unrelated to engineering field. (have a Bachelour of Law degree from some
mediocre university in Ukraine)
Had interview with one of FANG this summer in Hong Kong but failed it due to the fact that I suck in DSA.
After failure I reviewed my approach on learning algorithms and data structures. Below you can read
what I do since then. I believe the approach that I describe here may be interesting to you if you
struggle to find a right way to learn DSA. I also believe it will help me to succed in my next
interview with top tech companies.
I strongly agree with Clayton that in order to succeed at DSA interviews you need to be in an
Autonomous stage of knowing algorithms and data structures. Also, you should know the code
of their efficient implementation in your favourite language.
It is not an easy thing to achieve and only way to get it is a daily hard work on memorizing
solutions for tasks and actual code memorizing. I know some of you may not like the idea of
memorizing a solution and it may look boring, but in my opinion it is the only way to enable
your brain to solve programming problems. I also mean that while memorizing you ought to
understand the solution and algorithm you are using, not just relying on your visual memory of
code snippets or so on.
I grabbed this idea from Clean Coder book and since then I do my every day Coding Katas.
It is like Katas in Karate or some other eastern martial arts. You need to train your problem
solving "muscle" by everyday practicing in order to be efficient when time comes: at interview.
So when you discover some new interesting problem, after solving it and looking at others
solutions and finding most optimal and clean code, you may put it on a list in one of your daily
Coding Katas.
Following the advise from a book, I've been already doing my Coding Katas for several months
and I'm feeling it really makes a lot of difference. I'm becoming better at problem solving.
Everyday I have 2 - 3 problems to reherse. If I have enough time for repetition I'm practicing
it on paper first then retyping it to IDE.
Note: when practicing code on paper you may use some readable abbreviations to reduce time
you spend on writing long function names or classnames by your hand. Because it is really slower then
typing a code. As we all know some languages may be too verbal, as Java for example, and as practice
shows interviewers are ok if you make some reasonable abbreviations of class names and functions
during whiteboard coding interview. But make sure you let them know that you are using abbreviatins
to reduce time spend on writing them on whiteboard! It will be a plus for you during interview.
Examples of abbreviations I use with Java: HashMap -> HM, String -> Str.
You may use even something as .indexOf() -> .idx() if you agree with interviewier to use such
abbreviation for saving time. Most important, the code structure should remain the same as in your
language of choice. Don't think that your nasty pseudocode will be accepted during your interview :)
This is mentioned in a book: Cracking Coding Interview.
By the way, also do mention that you write a readable code usually with readable function names
and variables as a production code! No one wants a team meber who writes cryptic code with var names
such as x or y and function names do() and so on. Remember to mention that you are only doing
it as an exception for whiteboard coding.
I'm also following the idea I grabbed from this article: https://fs.blog/2018/12/spacing-effect/
The idea is the same as in learning new foreign language words. It works like word cards
repetition with intervals (like in memrise.com or anki). Some of you who learned foreign
language may already know that this method is efficient and proved in practice. The idea of
interval repetition is backed up by Hermann Ebbinghaus (1850-1909). He was a German
psychologist and pioneer of quantitative memory research. It is ground up on a fact that when
you are repeating one concept over and over with deep understanding of it, we are making strong
neuron connections in our brain. And it becomes easier for us to remember it, so yes you can be
autonomous in programming problems solving! Don't beleive it? Look at the videos of top leetcode
contest winners in youtube. They are like problem solving machines :)
I'm also using an Android app called Let's Review! (no free analog for iphone that i know) which
has a feature of reminding you your reviews for today, with your own set intervals. I'm doing
1-3-10-30-60 days intervals, according to article, and if say 30 days later I couldn't remember a
solution or made a mistake while repeating it on paper, I'm putting it on list from the day 1,
to make sure it is being remembered for good. There are some days I don't retype code in leetcode,
but I do practice it on paper at least.
Now I don't claim that you can become top coder at leetcode contests if you follow this method.
But it will help you to gain sufficient knowledge to get your dream job at top companies. After all it is
not all about your tech skills, it is also about your soft skills, and you can read a Soft Skills book by
John Sonmez to know more how to develop and maintain them.
Also to be successfull in your interview on a top of your strong DSA background, you should be also
keen using SOLID principles of OOP design in practice (autonomous coding of these concepts as you
wish) and know how to design efficient systems. But this is a whole different story not for this post :)
For a good free course on Algorithms, I recommend Princeton's series on coursera.com and you can
find and downlload their book for free online if you search well.
EDIT 1: As @vluu commented, you should not memorize the code untill you fully understand the
algorithm. I actually meant the same in this post but it appeared not clear. So to make sure you
get the message correct: learn algorithms concept first before memorizing the code.
Princeton's Course at coursera.com and their book is already a good start. They cover the most
important algorithms nowadays. You should understand a concept of algorithm and several different
applications of it to fully master it. Or in other words you should:
EDIT 2: as @thesourav has asked some recommendations on using Let's Review! app here are
some tips.
EDIT: 3 I've actually followed Clayton's advice to have a look at this free course:
https://www.coursera.org/learn/learning-how-to-learn
and it is really useful. I found the spacing effect I've descripbed in this post is also mentioned in
this course, but there are also more useful tips you can grab from there on being able to learn
efficiently.
The course may look too simple. But suprisingly there are no such courses at regular schools. Here
are some bulletpoints I grabbed from this course:
General tips (but not less important):
Thank you all for your attention!
I'm gonna go to a park now listening some audio book and after I get back home I'll do some leedcode problems and algos reviews ;)
Maybe some of you may apply my method in your DSA learning experience.
Wish you all good luck!
Paul