When I was introduced to the world of programming and my first 'Hello, World' program, the fact that I made a computer do that was absolutely fascinating for me.
Messing up with all the “if” and “else” nestings and loops in the blue screen editor for 'C' evolved me as a coder.
It was the same time I got introduced to the world of competitive programming and to websites like Hackerrank and Hackerearth.
I started out solving simple problems on these websites and gradually moved up to medium level problems that required basic to a medium level knowledge of data structures.
By chance I stumbled upon to this problem on Hackerrank. I didn't notice the 'Expert' tag mentioned besides the problem and hopped on to reading the problem description.
Now, being a total newbie to this world I had absolutely no idea of time and space complexity and how to optimize it. I just loved to brute force everything.
I read the problem description and thought how easily I can solve it, by, brute forcing it. And I did. And below were the results.
I wondered where I could go wrong, thought a lot about all the possible solutions and finally decided to post in the discussion forum for help.
And the reality hit me hard! Wha-at!? My code would take 316 years to execute. How's that even possible? I was shell-shocked and desperate to get this fixed.
Someone in the discussion said it, the problem would need 3D-DP to be solved, a term I was so alien to.
This opened a whole lot world of learning for me as a coder or I can best describe this as an incident which paved the way for me to strive to be a better coder every day. I decided to start with the basics of algorithms and time complexity. We've all been there.
It's been so long since then and I've come really a long way learning multiple problems solving techniques. I consider myself as a mediocre problem solver though and haven't really tried to solve this problem again in the past 3 years of time span but hope to pass all the test cases in my next attempt.
I just happened to be browsing through Hackerrank today when I found this and thought it'd make a great dev.to story.
Your thoughts on this? Have you been there too? Your story or experiences? And if by any means you happen to solve this problem, do share how did you solve.