Blending problem solving with software development

Spoiler alert: This post is not just about getting solution to some problem statement. Its more about understanding how competitive programmers and the “future” software developers should write their solutions. It is also not about the never ending debate of competitive programming(CP) vs software development.

Software development is more than just about getting green ticks/clearing test cases on hackerrank/leetcode/codechef. Its more about how well you write you appraoch problems, considering edge-cases, thinking about scaling the same solutions to larger codebase and most important documenting/commenting your approach for those problems.

Here, I present a ~few~ solutions to the Day4 May LeetCode Challenge. You can view problem statement here. I have included a potential code review section which can be helpful in understanding how technical recruiters might evaluate your code during interviews.

  1. Naive solution

Potential code review -
1. Space complexity isn’t that great.
2. Not a single pass solution.
3. Lots of logging involved here maybe the programmer isn’t confident on the use of STL libraries.
4. Integer overflow condition isn’t handled well.

2. Average solution

Potential code review -
1. Well written and easy to understand.
2. Handles overflow condition.
3. Good use of bit manipulation operations and const keyword.

3. Smart high-school math solution

Potential code review -
1. Well documented, short and less verbose code.
2. Difficult to understand at first glance without comments / approach.

Final thoughts -

  1. Usually its difficult to get intuition of last solution at first glance in the interview process. So the average solution is something that works ~okayish~ if you are facing the same problem in interview. The interviewers aren’t just looking for smart solutions; they are looking for well-written solutions. If you code something really smart but you are unable to explain it to your interviewers, all the smartness behind solution is futile.
  2. Usually you start with brute-force and work towards optimising your solution. When asked about optimisation aspects, “yes”, the interviewers are looking for something better from your solution/approach alike the smart solution. (FAANG’s, MSFT and other product-based firms want this!)
  3. Alongside problem-solving, system design, scalability, test-driven development and clean-code practices is something what recruiters are looking within you. Everything coupled above is makes a computer programmer the “real software engineer”

Software development != (CP)

Don’t blindly aim for green ticks / clearing test-cases; focus on getting better at software development 😄

Thanks for reading. Happy coding!

You can find me on LinkedIn , Github and Twitter



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store