DISCLOSURE: This post contains affiliate links, meaning when you click the links and make a purchase, we receive a commission.
Everyone who aims to become a Software Developer or a Data Scientist or a Mobile App Developer, needs to have a great understanding of problem-solving. It is not something that we’re born with. And every great skill comes only through practice. And the best way to become a great problem-solver, is by actually solving problems. Competitive programming is one of the most popular ways to develop this skill very effectively.
Competitive programming is basically about solving problems more effectively and efficiently, with solutions that run faster than others. So it basically trains your brain muscle to write code that uses fewer resources, takes less time to run, and above all, leverages the best algorithm to solve the problem at hand. Many popular competitive programming contests are happening around the world. Some of the most popular ones are
- International Collegiate Programming Contest (ICPC) — University students take part in groups of 3 each and one of the well-known contests.
- International Olympiad in Informatics (IOI) — Another well-known contest for secondary school students
- CodeChef — being conducted from 2009
- LeetCode Contests
- Google Code Jam
- Kaggle —competitions majorly focussed on data science and machine learning problems.
There is always an argument about what is the best language one can use for competitive programming problems to have better chances of winning. Most say C++ or Java is the go-to language for such contests. And Python is always overlooked considering its slow compilation and the nature of being an interpreted language. But still, we have a Python grandmasters in many coding competions. So it is basically not about the language, but it is the way in which one is implementing the solution for the scenario and how effective that solution is. For instance, one important factor that influences your victory over others is the time complexity of the algorithm. For Example :
To find the sum of first n natural numbers, two possible approaches :
With complexity O(n)
s = 0 for i in range(1,n+1): s+=i
With complexity O(1)
s = ( n* (n + 1 ) ) / 2
Therefore, the most important factor in solving a problem is selecting the appropriate strategy.
However, to be aware of the right strategy for solving a given problem, you need to know all the possible algorithms out there. Knowing all the possible algorithms is not simple; it’s tiring and tedious. And having the intuition of finding the right algorithm to solve a problem is not easy. And that is exactly what I’m going to help you with, in this article. One important resource that helps you to do this better is a book that can guide you in the right direction through this journey with the right details. And here I am with suggestions for some of the best books for preparing yourself to become a better competitive programmer using Python.
Lean back, have a coffee and read on.
By Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasse
This is indefinitely the best book for learning the data structures and algorithms concepts in detail in Python. Having covered all basic till advanced level data structures, this book stands out from others due to the following reasons:
- Very-well structured chapters which include all the nitty-gritties of a given topic without distracting too much at the same time providing proper mathematical explanations.
- Along with this, each data structure/algorithm is explained very clearly with relevant graphs and visual maps to understand them step-by-step.
- Every problem/algorithm discussed in the book has a complete and clear code solving/explaining the entire thing.
- For all the algorithms, there is a clearly stated analysis of its time complexity with well-explained reasoning.
- All operations for a given data structure are explained clearly with relevant real life examples in some cases.
- There are also exercises at the end of each section that helps to revise the learnt concepts and apply them to some more new problems for better understanding and practice.
This book is basically everything you need to make yourself knowledgeable of all the DSA concepts in Python and even if you’re a beginner to Python, the book begins by touching upon basic Python concepts, datatypes, OOPS concepts with reference to several design patterns. There are proper mathematical functions and graphs wherever needed to explain the concepts in detail.
The book stands as the most popular Python-based Data Structure book and also the 41st most popular book in algorithms section.
By Christoph Dürr and Jill-Jenn Vie
This is another great book that helps in reinforcing the skills learnt from the previous book and then getting ready for the actual competitive programming contests. This book is a translation from the French language edition: Programmation efficace — 128 algorithmes qu’il faut avoir compris et codés en Python au cour de sa vie by Christoph Dürr & Jill-Jênn Vie. As the name already tells, this book is a collection of 128 popular algorithms used in competitive programming contests that gives you the essential knowledge which can be leveraged to solve any problem of the similar kind. The 128 algorithmic problems collected here are indexed by theme rather than by technique. A lot of them are classic, whereas some are atypical. This is a highly recommended book to refer for competitive programming in python because of the following reasons:
- Develops a framework to tackle algorithmic problem solving, including: Definition, Complexity, Applications, Algorithm, Key Information, Implementation, Variants, In Practice, and Problems.
- Helps to learn about lesser known data structures like Fenwick trees and Knuth’s dancing links as well as popular problems like Dijkstra’s shortest path algorithm and Knuth-Morris-string Pratt’s matching algorithm.
- Has Python code that is present in the book and on the companion website highlights implementation issues and offers the complete source code for the majority of the algorithms discussed.
- It contains particularly clear and refined expression, illustrating the essential steps of the algorithm, without obscuring things behind burdensome notations describing data structures.
- Each section is clearly laid out and ideal for self study.
All the algorithms given would really help you in developing a mindset that is ready to face any given problem in the actual contest. This is another popular book, being one among the very few popular Python based competitive programming books.
Combining the power of these two books, it vests the great ability in you to crack any kind of competitive programming contest and becoming the next Python grandmaster.
Hope you found this article helpful and resourceful. Thanks for reading this! Please share your thoughts/comments on this!
Let’s make coding fun together!