leetcode.com is a site many people see as the one authority on programmer aptitude. Show that you can do a heap of leetcode problems and you’ve almost nailed the interview for your next programming job.

But.

There’s a problem.

The problems on leetcode have several problems actually:

  • no real-world relevance (this is hard to fight, I know. But hey, when was the last time you did you have to reverse a singly-linked list?).
  • hidden constraints in the “libraries” they are using. A real programmer’s best friend is the debugger, the mysterious stuff happening in leetcode’s own libraries (eg. for implementing linked lists) is going to thwart your efforts of even getting test data going.
  • the problems are just plain wrong. Easiest example, you are being asked to create your own atoi() function (converting a string to an integer). The problem is that leetcode uses a testcase which overflows the integere, then gives you a runtime error. The problem is unsolvable if you change the function signature, it has to return an int.
  • important edge-cases are almost never part of the examples, making it very hard to implement a correct solution, even with time-consuming techniques like test-driven design.

There are other sites where you can improve and show your coding and problem solution skills online, as eg. boot.dev, eldarverse.com, even adventofcode.com. Ignore leetcode, they are not worth your time.

(as an aside, last year I did Advent of Code in C, with gtest as the testing framework. I highly recommend that combination, it makes testing so easy, and you learn a lot of problem solving in C)