Lessons learned from practicing data structures and algorithm challenges

Here are some of lessons I have learned over the last few weeks solving problems at LeetCode, Geeks for Geeks, Pramp, and Hacker Rank.

  • Solving code challenges is fun! I love seeing the Green Check Mark or the PASS or earning points 🙂
  • Code challenges are very difficult. They can be very frustrating and upsetting. But the reward is learning the concept. Learning a concept, i.e. recursion, is like earning a key that opens up doors to both solving similar problems and to being able to understand more complex concepts (i.e. backtracking).
  • I used to just try to start coding by trial and error. That was a disaster. I have learned to really focus on using examples. I try to have a number of input and output examples including edge cases, smaller examples, and medium size examples.
  • After I have my examples, I need to be able to solve it in plain English first. I like to draw things out, i.e. the array with values, linked lists, trees, etc. Then I try to solve these examples in plain English.
  • If I have tested my plain English logic and things seem to work, then I will finally start to code. If my logic does not seem to work, I will start brainstorming possible solutions.
  • If at any point I get stuck, I will go for a walk or stretch.
  • The most important thing about the code challenges is that I am having fun doing them. As long as I keep on having fun, I will keep learning and improving my skills.
  • This is a great soundtrack to listen to while coding Crypt of the NecroDancer OST.
  • Everyone learns and improves at a different pace depending on their experience, natural aptitude, time and energy, etc. I have learned that I feel much better when I compare myself to my past self (and see how much I have improved) and to my future self (to see where I want to be), instead of comparing myself to others.
  • Instead of thinking, “I can’t solve this problem, I have never seen anything like this before :(” I am better off thinking, “Great, I now have the opportunity to learn something new :)”

The code challenges have tested my patience at times, but overall it has been great. I have learned and improved so much, I can’t wait to solve even more and bigger problems 🙂

LeetCode Update II

This was my previous LeetCode Update and this was my Original LeetCode post.

Before I was doing the LeetCode algorithm problems in order of difficulty. I was doing and redoing the problems in random topic order.

I am now doing the problems by category. I am not finishing the category until I am able to solve the problems in the category. I think this is an improvement because it is more drilling and practicing of recalling and typing the correct solution. It is definitely more difficult than just searching for patterns, but it is providing me with a better understanding of what each line of code does in a solution.

Also to make sure I can do new problems in random topic order I use TopCoder.

 

How she landed a Google internship in 6 months

Check out this great post by Joanna Chen: How I landed a Google internship in 6 months

She has has great advice on building, practicing coding problems (Pramp.com), meeting people, applying, etc.

Special thanks to Siddharth for being the first to introduce me to Pramp.com for free interview practice.

Data structures and algorithms practice resources

Here are the sites I have experience with and my thoughts

  • LeetCode is excellent because there are many problems and explanations. Furthermore the problems without explanations have answers and commented solutions in the discussion boards. It is the best online judge in my (limited) experience.
  • Code Wars is fun and great for learning a specific language and its features, i.e. JavaScript. But I did not find it as valuable for algorithms.
  • Cracking the Coding Interview has many questions and detailed answers in Java.
  • Data Structures and Algorithms Made Easy in Java is excellent. Sure there are many, many, many typos. But it has so many code samples for each of the data structures, explanations from worse (brute force) to best (optimized) along with advantages and disadvantages of the many possible solutions.

An honorable mention goes to Free Code Camp. The first time I ever had fun solving code challenges was at Free Code Camp. They did an amazing job of starting off with relatively easy challenges, then they raised the bar. Before I knew it I was doing difficult challenges, yet the hours flew by.

On improving as a developer…

In So You Want to Become a Better Programmer? John Sonmez recommends using code challenges to improve as a developer.

I would like to enter competitive programming contests but I am very rusty with my algorithms. I completed classes in data structures and algorithms, as well as assembly programming, in 2014.

I plan to improve at solving coding challenges by using LeetCode Online Judge. I will relearn and review the concepts by using these learning principles:
Making Badass Developers – Kathy Sierra
Chicken Sexers, Plane Spotters, and the Elegance of TAGteaching

My plan is to first go through all of the easy and medium questions quickly and just read and understand the solutions. This first round will simply be about relearning and reviewing the concepts. I will probably solve close to 0% of the problems 🙂

The second round I should be able to solve a third of the problems.

By the time I go through the questions for the third time, I should be able to solve two thirds of the problems or more.

Will this system work? Time will tell. But so far I am having fun and learning much with little stress from this first round. So far so good 🙂

On Data Structures and Algorithms…

I have started doing coding challenges at LeetCode. Even though I took a year-long Data Structures and Algorithms course in 2014, I am extremely rusty and cannot solve very many problems.

I was feeling overwhelmed until I saw this video: Watch Flavian solve three Rubik’s Cubes…BLINDFOLDED!

I read more about how he solved Rubik’s cubes while being blindfolded here: SpeedCubing win 2015 edition of Romania’s Got Talent with quick Rubik’s Cube solving.

This part stood out to me:

The group, called SpeedCubing, went on stage and solved Rubik’s cubes, blindfolded. This representation, for which they have memorized no less than 4,000 algorithms, got them the big prize of EUR 120,000.

I now feel much more confident about my goal to be able to solve problems by applying only a dozen or so algorithms–without a blindfold and without millions of people watching 🙂