I've been solving Leetcode challenges for over a year or so; I noticed that there is a great number of challenges that Devs are avoiding or failing to solve due to the challenge's quality.
Then, Leetcode tries to push those challenges to us via "Daily challenge" which frustrates a lot of people that Leetcode is trying hard to push Devs to do challenges that are poorly written.
Some red flags to recognize about a poorly written challenge:
Low Acceptance Rate
A challenge is not meant to be "Unsolvable". Leetcode challenges should aim to help Devs solve the challenges or have higher acceptance rate of submissions.
Poor Description
One of the worst things is poor description that leaves the Dev trying to guess what is being asked or very few test cases at the beginning that do not really help the Dev understand the core requirements.
I've often found myself writing a solution just to find myself being slapped by the test cases and adjusting/changing my code not because my solution is poor but because the description/requirements were not clearly communicated in the challenge.
So in this sense, if you spent 20 minutes writing a solution based on the description and you find yourself spending another 20 minutes adjusting your code, you easily lost 40 minutes.
Author's Solution or The High-way
What's worse than a poor description, is when the authors are forcing you to use their solution and accepting their solution as the "Ideal" or perfect solution. Most of those solutions fail several metrics such as readability and use lots of hackish techniques to squeeze few milliseconds when a more clearer solution with the same time complexity could have achieved the same result relatively; but they often place their time limits based on those hackish solutions.
In essence, time limits have become a tool that is abused by the authors to force Devs to accept/adopt their solutions instead of focusing on correctness, readability, etc... .
Time complexity should be the proper measure instead of how many milliseconds the solution takes (yep, hard coding here is still bad!). There are plenty of ways/tools in which they can spot the time complexity since there is already a built-in AI tool in Leetcode that does this so why not utilize it instead of hard coding time limits?!
If the author wants us to write an efficient solution, the focus shouldn't be on writing complicated unreadable solutions to prove how good they are at solving challenges but rather, focus on helping Devs solve the challenge with the desired time complexity without straining them or exhausting them with guessing and puzzles.
Ideally, what time complexity the challenge is solved with should be up to the Dev writing the solution while letting them also think for themselves on how to solve the challenge with better time complexity since Leetcode by default always will show the Dev the comparison chart against other solutions in terms of both time in milliseconds and memory usage.
How to Improve Challenges
The moment you think or believe that you want the Dev to "Learn" an algorithm or a technique, you need to ask yourself the question, in real life, at a company, are you going to dictate to your teammates how to write their code or solutions? If the answer is no, then by no means you should dictate in Leetcode how a solution is written; instead you should give the Dev a pathway to explore other paths without crippling them with strict test cases and TLEs (Time Limit Exceeded).
The difficulty of the challenge shouldn't be measured in how difficult is the description, or how much guessing the Dev has to do to figure out the solution but rather the difficulty should be in achieving the correct result of a complicated problem that might occur in real life.
If you adopt the above firmware (or mindset), you will be able to write more meaningful Leetcode challenges.
Maybe you can argue that on job interview, the challenges are quite often unfair, unclear and poorly communicated; this is a valid argument but then comes the question whether or not it's worth even working in such a toxic environment that is hell bent on making you feel hopeless or naive instead. That is a different problem and shouldn't be Leetcode's concern to make the challenges as poorly made as those on some job interviews.
A poor challenge or coding task on a job interview reflects on disorganized team and/or toxic environment which you shouldn't be in, in the first place!
What are your thoughts, please do share!
Top comments (0)