How solving problems in LeetCode is helping me?

Learn to code better, faster and cleaner

So How the *@#$ do I solve this?

A few weeks back, I launched my first iOS app with very basic knowledge on Swift that I learned through few tutorials and mostly Apple documentation. But then, I had no prior knowledge on any programming language and almost everything I learnt in Swift was new to me.

With a beginner’s knowledge of basic data types, conditional statements and loops, I started coding in Swift. Along the way of developing the app, I learnt and made use of certain iOS SDK and libraries.

As my knowledge grew, it was mostly on the app development itself and very less on the concepts of programming. To be specific here, on data structures and algorithms.

I published my app in the app store. While reviewing the app and talking about its scalability with my friends, I understood that I have a lot more to learn. Not just the programming language, data structures and algorithms but also about problem solving.

I believe in learning through experience and this way I learn faster, solve real-life problems and also stay motivated. So I was looking into websites on what I should learn and how I should start and was super confused with all different options available for beginners to learn programming. Luckily, one of my friends introduced me to Leetcode.

LeetCode:

LeetCode is a platform which allows anyone to solve programming problems with increasing difficulty. As I started solving problems, I feel LeetCode is a great platform to sharpen your skills on problem solving and coding. It supports Swift and hence I could also master the programming language eventually helping me build iOS apps faster and better.

How to get into the practice of solving problems:

  • First of all, have a goal in your mind on what you want to learn. For me, it was to code better and cleaner using proper OOPS concepts and also get a strong understanding of data structures and algorithms.
  • Start with the easy ones so you gain confidence. Then gradually move to medium/hard problems.
  • Try to solve in 40 mins. If you couldn’t find the solution, see the hints and then continue. As you start to feel more confident, reduce the time.
  • Don’t be hesitant to “GOOGLE” if you don’t understand something. When I say google, don’t google the problem itself. Google on your ideas to solve the problem and see how you can implement them.
  • For Data Structure(DS) learning, first make a list of data structures that you want to get hold of. Then read about those in google, GeeksforGeeks, etc and once you get some knowledge, implement the DS in the programming language of your choice first before solving problem using DS.
  • Then search for a problem with the data structure’s implementation in LeetCode. Solving this way helped me in understanding how a particular type of data structure can be applied to a problem.
  • Test your code and submit. If your code did not pass, don’t give up. Try fixing the errors, until you get it right.

Major learnings from LeetCode:

  • Understanding of Object Oriented Programming.
  • Better Problem Solving.
  • Started mastering time and space complexities.
  • Understanding Hash Tables and B-tree. Basically, I started developing knowledge on data structures, which made my problem solving skills better and efficient.
  • Finally, making me test my code better. One of LeetCode’s major resource is its test cases. The first few times I submitted my code, though I knew I solved the problem I ended up failing while testing. With the failure, I started to understand that I need to test special cases and slowly this helped me in developing better, error free and strong testing habits.
Once you get hold of it, don’t stop it. You can take contests or solve more. Keep coding and stay active. If you practice enough in LeetCode, you will easily get a job in your dream company.