My solutions for many various coding/algorithmic problems (this repo will be updated with new solutions from time to time).
All solutions are written in Python (more precisely, Python 3), using the Built-in Functions and few modules from the Python Standard Library like:
- math (used for constants like math.pi, math.inf and functions like math.ceil, math.floor, math.gcd, math.log, math.pow, math.sqrt, etc)
- collections (used for collections.deque when there is a need for Stack or Queue data structures)
- heapq (used when there is a need for Priority Queue data structure).
So, to execute these solutions there is no need from installing any external packages.
Coding style and name conventions are described in this file PEP8.
These problems are from sites like LeetCode (you can find more than 30 sites like this in the Training Sites section).
Also in this README you can find many resources for learning algorithms: Courses, Books, Training Sites, Other Resources.
Each solution/problem in this repo belongs to one of these categories:
Each file with solution in this repo will have the following template:
'''
Problem name
Problem explanation
Input: XXX
Output: XXX
Output explanation: XXX
=========================================
Solution explanation
Time Complexity: O(X)
Space Complexity: O(X)
Solution 2 explanation
(some of the problems are solved in more than one way)
Time Complexity: O(X)
Space Complexity: O(X)
'''
############
# Solution #
############
def name_of_problem(params):
# description of code
pass
##############
# Solution 2 #
##############
def name_of_problem_2(params):
# description of code
pass
###########
# Testing #
###########
# Test 1
# Correct result => 'result'
print(name_of_problem('example'))
# Test 2
# Correct result => 'result2'
print(name_of_problem_2('example2'))Collection of free courses from one of the best CS universities.
-
Princeton University (Coursera)
-
MIT University (YouTube)
-
Harvard University (YouTube)
-
UC Berkeley
Several books that have made an impression on me:
- Grokking Algorithms by Aditya Bhargava - The best book for complete beginners in algorithms! I wish this book existed when I started learning algorithms.
- Introduction to Algorithms by Thomas H. Cormen
- Algorithms by Robert Sedgewick & Kevin Wayne
- The Algorithm Design Manual by Steven Skiena
- Geeks For Geeks - The site which all interested in algorithms (no matter if beginners or experts) should know!
- The Algorithms - Python - Great GitHub repo with many algorithms written in Python.
- KhanAcademy - Algorithms - Good explanations for some basic algorithms.
- HackerRank - YouTube tutorials
If the problems from LeetCode are not enough and you need more problems like those, you can find much more on these platforms:
- HackerRank
- CodeChef
- HackerEarth
- CodeForces
- Topcoder
- Project Euler
- Codility
- CoderByte
- CodingBat
- CodeAbbey
- Wolfram Challenges
- CS Academy
- Daily Coding Problem
- Daily Interview Pro
- Codewars
- SPOJ
- Online Judge
- LintCode
- DevPost
- USA CO
- CodeFu
- Mendo
- Kattis
- AlgoExpert
- Brilliant
- Kaggle
- Codingame
- CheckiO
- Rosalind
- CodeKata
- FightCode