Algorithms and Data Structures Are the GOAT

2021/08/21

Preface

My new job is officially locked in. Looking back at my recent job-hunting process, I’ve gotta admit I’ve been way too comfortable slacking off at work—only when you start looking for a new job do you really realize where you’re lacking. Throughout this whole process, I feel like I’ve grown a lot. Besides getting way smoother at reciting all that “interview boilerplate,” I also met a bunch of excellent interviewers. I even added a few big shots on WeChat. Even though I didn’t end up joining their teams, I really hope we can stay in touch, because they’re just that good.

One weakness that stood out especially clearly for me is algorithms and data structures. As for grinding problems—honestly, I did train back in school, but after years of being “washed” by business code, I’d basically forgotten most of it. Since I’ve been job hunting recently, I started preparing again. Time was tight and I was pretty utilitarian about it, so yeah… I’m still pretty bad. But companies around Wuhan don’t test this part that much. And even when they do, it’s mostly Easy problems. I’ve even had Merge Two Sorted Lists show up at two different companies.

But this recent prep gave me a huge mindset shift. Back in school, when I learned C and did after-class exercises, or learned data structures and did related problems, I had no project experience, and my actual coding was basically just writing demos. So grinding problems felt hollow—just mechanically meeting the requirements, without my own understanding. Now, with more years of work and more project experience, plus a deeper understanding of certain data structures and business scenarios, doing algorithm problems feels totally different. It’s actually interesting. Besides being amazed by some superhuman solution ideas, I also learn a lot just from reading discussions and other people’s code style in the editorials.

It feels like writing business code every day and memorizing interview boilerplate made me ignore the basic qualities an engineer should have. So I decided that from now on, every night before bed I’ll do a bit of practice—keep my “problem-solving feel,” and prevent dementia in old age. Practicing regularly also makes you pay more attention to the quality of your code—for example, evaluating space complexity, time complexity, and balancing readability with conciseness. I once heard a quote from Mr. Qin Chao on Geek Time that really makes sense: if a programmer writes code without caring about time complexity, it’s like a sailor navigating the ocean without caring about fuelit’s extremely dangerous.

Here are a few OJ platforms I think are pretty good.

  1. Luogu - less utilitarian, more contest-oriented

Luogu is still super popular among students. From NOIP to ACM enthusiasts, lots of people train there, and there are weekly contests too. The problems lean a bit toward competitive programming. Besides basic coding ability and flexible use of data structures, what matters even more is mathematical thinking. For me… emmmmm… maybe it’s just not that suitable at this stage.

  1. PAT - clear difficulty gradient, more fundamentals-oriented

PAT is an exam created by Grandma Chen Yue from Zhejiang University. It’s mainly practice problems, with levels from Basic to Advanced, corresponding to beginner, intermediate, and hard. Beginner tests programming fundamentals, intermediate tests basic data structures, and advanced covers classic algorithms and advanced data structures. The gradient is pretty fine-grained—for example, the beginner problems are basically like the exercises at the end of many syntax textbooks. Doing them on an online OJ is pretty nice.

The two above are more academic. The two below are closer to industry and more utilitarian.

  1. LeetCode (CN) - LeetCode is one of the most frequently opened sites among problem grinders in the Greater Bay Area -

The problems here are all very classic. And because they’re classic, you’ll see a lot of original questions from big tech companies. Many companies also directly pick problems from there to test candidates. I personally practice mainly on this platform, because there are lots of algorithm enthusiasts sharing solutions, and also lots of noobs like me whining in the comments, complaining that they’re so bad they can’t even understand the problem statement 😂. It feels very real, and people online are genuinely funny.

LeetCode itself is free—whether you pay or not, it provides the basic features. But it also offers value-added services. After subscribing, you can access some exclusive problems (but the regular problems are more than enough, and classic sets like 剑指 Offer aren’t paywalled either, which is pretty decent), plus online debugging, faster judging, etc. After all, compute resources cost money. Getting the core features for free is already great.

But I still bought a one-year subscription. It’s not cheap—500 RMB a year. Besides wanting to experience the member features, I also wanted to remind myself that I paid for it, so I should use it every day and not waste it.

leetc

Spent a fortune on a one-year plan, forcing myself not to waste the money


  1. Jiuzhang Algorithm - kind of a LeetCode competitor; I recommend it purely because you get 7 days of membership for signing up….

The problems there are also pretty good. Worth mentioning: their database problems are free, while LeetCode’s database problems are basically member-only. If you want to improve your SQL, you can go to Jiuzhang and grind all the database problems there. There are downsides too—since fewer people use it, the overall ecosystem might be a bit lacking. By “ecosystem” I mean editorials and comments. For a noob like me, one really important part of grinding problems is the solutions. When a platform has enough users, no matter the skill level, there will always be helpful people sharing their approaches—and you’ll eventually find one you can understand. Otherwise, stubbornly banging your head against a single problem is honestly a waste of time.

Just grinding problems with your head down isn’t actually the best way to improve. The further you go, the more obvious the diminishing returns become. You need to be good at summarizing, or read summaries from the pros. So here I’m recommending some resources I’ve saved—basically summaries made by experts. Because in the end, data structures and problem-solving patterns boil down to just a few common types.

  1. Grokking Algorithms (Illustrated) - this is a book, a must-read for beginners. Go through common data structures and approaches once; it helps a lot with problem grinding. No rote memorization. You can read it for free on WeChat Reading.
  2. The Art of Programming: Interview and Algorithm Insights - also a book. The physical version is sold on JD, but it’s essentially a compilation of the author July’s articles from GitHub. This link is basically the electronic version before the final print edition. I think the quality is very high; I learned a ton from it.
  3. Xiao Wu Algorithms - an animation-based, illustrated algorithms site made by a big shot. It regularly breaks down problems. Some solutions are really abstract, but presented as drawings they become super clear.
  4. leetCode-Go - a big shot solved all LeetCode problems and turned it into an e-book. The highlight is that the solutions are 100% top-tier, written in Go. They keep updating it as LeetCode adds new problems, and it’s free—pure passion project. That’s really rare.

Epilogue

Originally I just wanted to say that I bought a LeetCode membership and set a flag, hoping everyone would supervise me. No idea why, but as I kept writing it turned into a sharing post. I’m really bad—I’ve only done about 50 problems so far, and I’m slowly grinding through more. Right now I genuinely feel that practicing problems is interesting, and also pretty important. That importance isn’t just about the utilitarian “interview” side of things—it’s more about an engineer’s professional fundamentals. And LeetCode’s comments are seriously hilarious. Here are a few fun ones I found:

A cup of tea, a pack of cigarettes, one LeetCode problem for the whole day. One pen, two hands, one bug hammered out all night.

First thing every morning: check LeetCode; every time I look at the daily problem, I feel my brain shutting down; think for two hours, then copy from the editorial; check in, I must check in, grab the points and fool myself — burning my LeetCode problems.

A LeetCode a day keeps unemployment away.

Some people fall in love, some people drive at night to watch the sea, and some people can’t even solve LeetCode Problem #1.

All articles in this blog, unless otherwise stated, are licensed under @Oreoft . Please indicate the source when reprinting!

Table of Contents