Leetcode is like Gymming

Classical musicians must learn specific techniques to master their instrument. Violinists, pianists and opera singers have a rigid schedule since childhood - master specific scales, practice with increasing tempo, and repeat. Athletes and bodybuilders have to follow specific diets for their body - following a course of nutrition and a set training program that burns these many calories, will bring body fat percentage to x%. These techniques have been learned and refined since generations.

Programming is developing similar rules like the above. Learn some specific techniques - binary search/backtracking/memoization etc and you will have learned the standard basics of programming. Leetcode builds up your ‘mind muscles’ similar to how bodybuilders follow progression paths in the gym - it’s a repeatable and standard pool of questions to solve, which progressively build up your familiarity and speed.

During the early days of programmming - the 80s and 90s - a pop-culture image had formed of a ‘typical’ programmer - a hacker, a mysterious and shadowy figure, generally rebellious with an anti-social persona (which unsurprisingly mostly consisted of college-educated white males). Now we know better - anyone can learn the basics of programming by putting in the time and following a standard course of knowledge. You don’t need to be a nerd, you don’t need to spend ALL your time programming, or any other stereotype. You just need to be smart enough (and by smart I mean someone who is able to effectively identify and improve their knowledge wherever they are weak/uncomfortable).

Most programming sites are converging on the same types of questions - the leetcode format. This is a good thing - anyone from a sulky teenager in Taiwan to a 30-year-old widow in Africa may train on these questions, and if their natural aptitude is of the thinker kind - or if they’re just desperate for money, really - they will achieve a level of programming skill. And just like people are attracted to fit and muscular members of the opposite sex, so are companies and businesses attracted to muscular and brawny programmers, who ‘flex’ their ‘brain muscles’ during programming interviews.

TLDR; Leetcoding helps programmers. Gymming helps bodybuilders. Deliberate practice helps musicians. Imagine a musician trying to play classical music just by ear, without practicing techniques like sightreading and scales, and trying to wing it/rediscover the basics on their own. Imagine a bodybuilder trying to lift a 250kg log in the forest without lifting dumbells in the gym first. Imagine a programmer trying to implement a distributed dependency solver algorithm without practicing recursion questions first.

Caveats:

This is not to say that every programmer MUST be a leetcode grinder - many people have learnt the same intuition/knowledge by working on their own projects. As a result, their mind has gotten sharp enough on their own. But that may be a more difficult way of going about the same thing, while the end result is the same - a disciplined and toned/stretched mind (the pleasure people derive from their own projects varies, of course).

Also, not every job needs the kind of skill gotten from leetcode grinding. A fullstack developer doesn’t need to learn dynamic programming, just like a marathon runner doesn’t need to be able to deadlift 200lbs. It would be a waste of time for the academic researcher or fullstack developer to flex their ‘algorithmic thinking’ muscles. As long as their ‘muscles’ are flexed by other means, they don’t need leetcode.

Also, leetcoding questions are only useful after you have achieved a basic familiarity with programming idioms. Every programmer must spend some time learning about functions, control flow, the standard library and various frameworks in languages like Javascript, C++, Python etc.

And finally, Leetcode is still no substitute for domain knowledge, architectural intuition, intellectual curiousity or plain hard work.

Written on April 9, 2019