HackerRank Python First Half Review
After a recent coding interview didn’t go as well as I would have liked, I decided to grind some HackerRank interview prep questions both for the practice, as well as for the proof that I know what I’m doing. At present, I’ve completed half (58/115) of the Python HackerRank interview prep problems in about 1 week, and I’m on my way to completing all of them. Here are some thoughts I have about these problems, and predictions for the second half.
The vast majority of these problems are very straightforward for me, but there are some that confound me for hours at a time. Most of the time, I was able to figure things out on my own, but sometimes it was useful to look at other people’s answers to see why my solution wasn’t working. Most of the time, it was my own problem, for example in a timedelta challenge I wasn’t getting the absolute value of the deltas, and that was required for the output to be correct. Some questions had bizarre gotchas that I don’t think I’d ever have been able to identify on my own. There was one specific question I remember that, in order to get the right answer, you had to sort only one of the inputs in reverse order to get the right answer. There was no indication that this would be required for the solution When I looked at the HackerRank forum post about this question, a ton of people were complaining about this particular question. It seems like either the instructions or the problem solutions should be updated.
The quality of the instructions and the boilerplate code provided to you at the start of the problem varies widely. Some questions have you working within your own function, with inputs already provided to you, and other questions don’t give you a single line of code to start with. As such, you learn a lot about input()
and type coercion. In my professional career, I don’t use input()
directly ever, and types are often automatically inferred or defined with the libraries I use for input, so I got used to using some idioms around input()
I usually wouldn’t use. What the real-world value is of those idioms is questionable, but oh well.
Another thing I got much better at as a result of HackerRank is formatting output. The test cases for every issue required very specific output formats, and they weren’t always clear. I often spent more time on formatting output than on the actual problems presented. A few things I learned about formatting with .format()
, like space padding and justifying variables to one side or another of my output, which I also usually wouldn’t use, because I’m fully on board with using f-strings in my personal and professional code.
For the second half, I expect questions to get harder, and as a result, to slow down in my progression. I expect more weird formatting problems, and to have a few more head scratchers that will become a lot more clear after I go for a walk. I’m kind of curious how many people have bothered to completely clear all these challenges. If I remember right, I started out ranked in the millions, but I’m presently ranked about 60k for Python at the halfway point.
After I clear Python, I’ll probably move on to the Data Structures and Algorithms practice track. We’ll see how fast I can crush that next!