To learn more about the newsletter, check our detailed About Page + FAQs
To help me understand you better, please fill out this anonymous, 2-min survey. If you liked this post, make sure you hit the heart icon in this email.
Recommend this publication to Substack over here
Take the next step by subscribing here
Happy Thursday my loves,
Based on the poll yesterday you’re down for more problem-solving oriented problems. I’m glad because I got a faaaattttt stack of them. I’ll mix them in occasionally to keep things fresh. Since I was experimenting with a new kind of question, I kept yesterday’s question on the easier end. And this way you can really focus on the principles instead of getting confused by the problems.
As y’all get better, I’ll raise the difficulty levels. And believe me, I got some doozies in the pocket.

FYI, Our super amazing 90% discount runs out in 3 days. Just as a reminder this would drop the prices in the following ways-
Monthly Plan- 800 INR (10 USD)—>80 INR (1 USD)
Annual Plan- 8000 INR (100 USD)—>800 INR (10 USD).
Don’t miss these savings. Just as a reminder, you can also buy subscriptions for other people as a gift.
Problem
Three of the robots, all from different models, have missing model IDs:
Rae is not the newest.
Knuck is the oldest.
Lex is not the oldest.
What’s the correct order from the newest to the oldest?
Step 1: Reading the Problem
You’re probably surprised by this, aren’t cha? Did you think that the steps would be different because this is not a Leetcode problem? Think again. The procedures and problem-solving techniques are the same, just in a different context. They will carry over directly to your Leetcode interviews.
The process for reading the problem is the exact same. We will first look through the expected inputs and outputs. These will help with our functions. Let’s note them down-
Input- 3 Robots.
Output- The age of the models. Let’s assume we’re returning a list [youngest, 2nd, oldest].
With this, we have the first step out of the way. You might think this is a trivial thing to do but don’t underestimate the power of clarity. There is a reason that writing function stubs is so helpful when writing code for systems. It’s one less thing to worry about. Yes, it’s small, but little wins really stack up. So where do we go from here?
Step 2: Eliminating variables
We have been given 3 rules. I’ll copy them below for convenience.
Rae is not the newest.
Knuck is the oldest.
Lex is not the oldest.
A good strategy for solving problems is to try to eliminate the variables in your problems. Variables here refer to any possible moving part of your solution. When it comes to your Leetcode solutions, this will reflect itself as solving the base cases/easy coding cases first. I often refer to this as picking the low-hanging fruit, and it is an extremely effective way of building your solutions incrementally.
In this case, condition 2 is a fairly obvious pick as the low-hanging fruit. But what if conditions are not very clear? Here is a great way of identifying them.
Step 3- Calculating the Entropy of a Condition
I know that the title is very fancy, but the process is simpler than you would realize. We do the following-
Look at every choice individually
For every choice look at the number of possible choices, we are eliminating.
The one that kills the most choices is the condition that is the best path forward.
Let’s see each of our 3 conditions and see which of them is eliminates the most options-
Looking at only condition 1, we know that Rae can go into 2 places (oldest and 2nd). Similarly, we can have the other either of the remaining 2 robots in the other location (and one of the non-Rae bots is the newest). We have 2*2- 4 possibilities.
If we have Knuck eliminate a place then there are only 2 options for the other places (either Rae is the newest or 2nd). More generally, if we have n robots, and I told you the location of one robot, then you’re only left with (n-1)! locations. If you’re looking to work your combinatorics, take a look at the question below.
Same as 1.
Based on this we know that condition 2 is the best foot forward (which aligns well with common sense). As a fun fact for you, a more complex cousin of this approach is used by the Machine Learning models called Decision Trees. Despite the hype around Deep Learning, Tree based models have been the most successful. To learn more about this, check out this article where I broke down why. The approach is called calculating entropy, and I will cover it on Math Monday.
This approach a variant of the Technique Case by Case analysis that I use a lot in the solutions. It comes with a lot of benefits, as detailed below. To learn more, check out the post I did on that Technique here.

So what do we do from here?
Step 4: Applying the Technique Again
One of the benefits of following this problem-solving strategy is that you can do it again with your new conditions. Given our analysis, we have the following conditions-
Rae is not the newest.
Knuck is the oldest.Lex is not the oldest.
Notice that condition 3 doesn’t add any more value. So we can skip it. This leaves us with condition 1. Adding that into our solution we know that Rae can’t be 1st. Thus, it has to be 2nd (the only remaining spot). This gives us the solution-
[L, R, K]
You could have solved this problem without doing any of these steps. This question was simple enough to do so. However, that would defeat the point. The easy difficulty of the question will allow you to focus on the principles of the techniques used and really understand them without being confused by all the chaos of harder questions. Make sure you really understand each step we took, why we made certain decisions etc. You will see the same ideas pop up in much tougher questions. You can take a look at any of the other solutions covered here for examples.
Loved the solution? Hate it? Want to talk to me about your crypto portfolio? Get my predictions on the UCL or MMA PPVs? Want an in-depth analysis of the best chocolate milk brands? Reach out to me by replying to this email, in the comments, or using the links below.
Stay Woke. I’ll see you living the dream.
Go kill all,
Devansh <3
Reach out to me on:
Instagram: https://www.instagram.com/iseethings404/
Message me on Twitter: https://twitter.com/Machine01776819
My LinkedIn: https://www.linkedin.com/in/devansh-devansh-516004168/
My content:
Read my articles: https://rb.gy/zn1aiu
My YouTube: https://rb.gy/88iwdd
Get a free stock on Robinhood. No risk to you, so not using the link is losing free money: https://join.robinhood.com/fnud75