Here you can find notebooks with solutions for various challenges that focus on algorithms and data structures found in coding interviews.
Each challenge has one or more reference solutions that are:
- Fully functional
- Unit tested
- Easy-to-understand
Notebooks also detail:
- Constraints
- Test cases
- Algorithms
- Big-O time and space complexities
Also, this repo will be updated with new solutions and resources from time to time.
Note that this repo is meant to be used for learning and researching purposes only and it is not meant to be used for production.
All solutions are written in Python (more precisely, Python 3), using the Built-in Functions (print, len, range, sorted, sum, min, max, etc...) and a 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).
- random (used for nondeterministic algorithms, like shuffling arrays (Fisher–Yates shuffle), sampling arrays (Reservoir sampling) and Monte Carlo methods).
So, to execute these solutions there is no need from installing any external packages.
Coding style and name conventions are described in the official PEP8 page.
Note that I'm not the author of these problems, they are from sites like LeetCode (you can find more than 40 sites like this in the Training Sites section). Only the solutions and explanations are mine.
- Eg Leetcode, Geeksforgeeks etc
- States the problem to solve.
- Input parameters
- Output result
- Describes any constraints or assumptions.
- Describes the general and edge test cases that will be evaluated in the unit test.
- Describes the pattern and technique used to solve the problem.
Each solution/problem in this repo belongs to one of these categories:
- Arrays - Array Manipulations, Sorting, Binary Search, Divide and Conquer, Sliding Window, etc.
- Linked Lists - Linked List Searching, Pointer Manipulations, etc.
- Trees - Binary Search Trees, Tree Traversals: Breadth-First (Level Order) Traversal, Depth-First Traversal (Inorder, Preorder, Postorder), etc.
- Hashing DS - Hashing Data Structures: Sets/HashSets and Dictionaries/HashMaps.
- Dynamic Programming - 2D and 1D Dynamic Programming, LCS, LIS, Knapsack, etc.
- Strings - String Manipulations, Reversing, Encodings/Decodings, etc.
- Math - GCD, LCM, Factorization, Geometry, Math Formulas, etc.
- Other - Backtracking, BFS, DFS, Stacks, Queues, Deques, Priority Queues (Heaps), Matrices, etc.
coding-challenges # Repo
├─ Arrays # Category of challenges
│ ├─ rotation.ipynb # Solution notebook
│ ├─ compress_solution.ipynb
│ ├─ ...
├─ linked_lists
│ ├─ palindrome
│ ├─ ...
├─ ...
Run:
pip install jupyter
For more details on notebook installation, follow the directions here.
More information on IPython/Jupyter Notebooks can be found here.
$ git clone https://github.com/sagarneeli/coding-challenges.git
$ cd interactive-coding-challenges
$ jupyter notebook
Feel free to contact me to discuss any issues, questions, or comments.
My contact info can be found on my GitHub page.
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
- SPOJ
- A2OJ
- PEG
- Online Judge
- E-Olymp
- VJudge
- DMOJ
- USA CO
- Rosetta Code
- AtCoder
- Russian Code Cup
- LintCode
- Kattis
- CodeAbbey
- CS Academy
- Advent of Code
- Exercism
- CodeFu
- Mendo
- Z-Training
- Codewars
- Wolfram Challenges
- Google's Coding Competitions
- Cyber-dojo
- CodingBat
- CodeKata
- BinarySearch
- Daily Coding Problem
- Daily Interview Pro
- AlgoDaily
- Codility
- CoderByte
- AlgoExpert
- Edabit
- DevPost
- Brilliant
- Codingame
- CheckiO
- FightCode
- Kaggle
- Rosalind
- Geeks For Geeks - The site which all interested in algorithms (no matter if beginners or experts) should know! YouTube channel with many useful videos.
- The Algorithms - Python - Great GitHub repo with many algorithms written in Python (Link from the same repo written in other programming languages).
- CP Algorithms - Great page with excellent explanations for various algorithms.
- Visualizers:
- USFCA Visualization Tool - Great tool for visualizing data structures and algorithms, created by the University of San Francisco.
- VisuAlgo - Another great tool for visualizing data structures and algorithms through animation.
- Algorithm Visualizer - Interactive online platform that visualizes algorithms from code. This platform is an open-source project, here you can find the source code.