Interactive Python coding interview challenges (algorithms and data structures). Includes Anki flashcards.

Subscribe to updates I use interactive-coding-challenges

Statistics on interactive-coding-challenges

Number of watchers on Github 12405
Number of open issues 33
Main language Python
Average time to merge a PR 2 days
Open pull requests 31+
Closed pull requests 13+
Last commit 10 months ago
Repo Created over 3 years ago
Repo Last Updated 10 months ago
Size 7.38 MB
Organization / Authordonnemartin
Page Updated
Do you use interactive-coding-challenges? Leave a review!
View open issues (33)
View interactive-coding-challenges activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating interactive-coding-challenges for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


120+ continually updated, interactive, and test-driven coding challenges, with Anki flashcards.

Challenges 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

Challenges will soon provide on-demand incremental hints to help you arrive at the optimal solution.

Notebooks also detail:

  • Constraints
  • Test cases
  • Algorithms
  • Big-O time and space complexities

Also included are unit tested reference implementations of various data structures and algorithms.

Challenge Solutions

Anki Flashcards: Coding and Design

The provided Anki flashcard deck uses spaced repetition to help you retain key concepts.

Great for use while on-the-go.

Design Resource: The System Design Primer

Looking for resources to help you prep for the System Design and Object-Oriented Design interviews?

Check out the sister repo The System Design Primer, which contains additional Anki decks:

Notebook Structure

Each challenge has two notebooks, a challenge notebook with unit tests for you to solve and a solution notebook for reference.

Problem Statement

  • States the problem to solve.


  • Describes any constraints or assumptions.

Test Cases

  • Describes the general and edge test cases that will be evaluated in the unit test.


  • [Challenge Notebook] Empty, refer to the solution notebook algorithm section if you need a hint.
  • [Solution Notebook] One or more algorithm solution discussions, with Big-O time and space complexities.


  • [Challenge Notebook] Provides on-demand incremental hints to help you arrive at the optimal solution. Coming soon!

Code (Challenge: Implement Me!)

  • [Challenge Notebook] Skeleton code for you to implement.
  • [Solution Notebook] One or more reference solutions.

Unit Test

  • [Challenge Notebook] Unit test for your code. Expected to fail until you solve the challenge.
  • [Solution Notebook] Unit test for the reference solution(s).


Challenges Categories

Format: Challenge Category - Number of Challenges

Total number of challenges: 120

Reference Implementations: Data Structures

Unit tested, fully functional implementations of the following data structures:

Reference Implementations: Algorithms

Unit tested, fully functional implementations of the following algorithms:

Reference Implementations: TODO

Installing and Running Challenges



Image Credits

Arrays and Strings

Challenge Static Notebook
Determine if a string contains unique characters ChallengeSolution
Determine if a string is a permutation of another ChallengeSolution
Determine if a string is a rotation of another ChallengeSolution
Compress a string ChallengeSolution
Reverse characters in a string ChallengeSolution
Given two strings, find the single different char ChallengeSolution
Find two indices that sum to a specific value ChallengeSolution
Implement a hash table ChallengeSolution
Implement fizz buzz ChallengeSolution
Find the first non-repeated character in a string ContributeContribute
Remove specified characters in a string ContributeContribute
Reverse words in a string ContributeContribute
Convert a string to an integer ContributeContribute
Convert an integer to a string ContributeContribute
Add a challenge ContributeContribute

Linked Lists

Challenge Static Notebook
Remove duplicates from a linked list ChallengeSolution
Find the kth to last element of a linked list ChallengeSolution
Delete a node in the middle of a linked list ChallengeSolution
Partition a linked list around a given value ChallengeSolution
Add two numbers whose digits are stored in a linked list ChallengeSolution
Find the start of a linked list loop ChallengeSolution
Determine if a linked list is a palindrome ChallengeSolution
Implement a linked list ChallengeSolution
Determine if a list is cyclic or acyclic ContributeContribute
Add a challenge ContributeContribute

Stacks and Queues

Challenge Static Notebook
Implement n stacks using a single array ChallengeSolution
Implement a stack that keeps track of its minimum element ChallengeSolution
Implement a set of stacks class that wraps a list of capacity-bounded stacks ChallengeSolution
Implement a queue using two stacks ChallengeSolution
Sort a stack using another stack as a buffer ChallengeSolution
Implement a stack ChallengeSolution
Implement a queue ChallengeSolution
Implement a priority queue backed by an array ChallengeSolution
Add a challenge ContributeContribute

Graphs and Trees

Challenge Static Notebooks
Implement depth-first search (pre-, in-, post-order) on a tree ChallengeSolution
Implement breadth-first search on a tree ChallengeSolution
Determine the height of a tree ChallengeSolution
Create a binary search tree with minimal height from a sorted array ChallengeSolution
Create a linked list for each level of a binary tree ChallengeSolution
Check if a binary tree is balanced ChallengeSolution
Determine if a tree is a valid binary search tree ChallengeSolution
Find the in-order successor of a given node in a binary search tree ChallengeSolution
Find the second largest node in a binary search tree ChallengeSolution
Find the lowest common ancestor ChallengeSolution
Invert a binary tree ChallengeSolution
Implement a binary search tree ChallengeSolution
Implement a min heap ChallengeSolution
Implement a trie ChallengeSolution
Implement depth-first search on a graph ChallengeSolution
Implement breadth-first search on a graph ChallengeSolution
Determine if there is a path between two nodes in a graph ChallengeSolution
Implement a graph ChallengeSolution
Find a build order given a list of projects and dependencies. ChallengeSolution
Find the shortest path in a weighted graph. ChallengeSolution
Find the shortest path in an unweighted graph. ChallengeSolution
Add a challenge ContributeContribute


Challenge Static Notebooks
Implement selection sort ChallengeSolution
Implement insertion sort ChallengeSolution
Implement quick sort ChallengeSolution
Implement merge sort ChallengeSolution
Implement radix sort ChallengeSolution
Sort an array of strings so all anagrams are next to each other ChallengeSolution
Find an item in a sorted, rotated array ChallengeSolution
Search a sorted matrix for an item ChallengeSolution
Find an int not in an input of n integers ChallengeSolution
Given sorted arrays A, B, merge B into A in sorted order ChallengeSolution
Implement a stable selection sort ContributeContribute
Make an unstable sort stable ContributeContribute
Implement an efficient, in-place version of quicksort ContributeContribute
Given two sorted arrays, merge one into the other in sorted order ContributeContribute
Find an element in a rotated and sorted array of integers ContributeContribute
Add a challenge ContributeContribute

Recursion and Dynamic Programming

Challenge Static Notebooks
Implement fibonacci recursively, dynamically, and iteratively ChallengeSolution
Maximize items placed in a knapsack ChallengeSolution
Maximize unbounded items placed in a knapsack ChallengeSolution
Find the longest common subsequence ChallengeSolution
Find the longest increasing subsequence ChallengeSolution
Minimize the cost of matrix multiplication ChallengeSolution
Maximize stock prices given k transactions ChallengeSolution
Find the minimum number of ways to represent n cents given an array of coins ChallengeSolution
Find the unique number of ways to represent n cents given an array of coins ChallengeSolution
Print all valid combinations of n-pairs of parentheses ChallengeSolution
Navigate a maze ChallengeSolution
Print all subsets of a set ChallengeSolution
Print all permutations of a string ChallengeSolution
Find the magic index in an array ChallengeSolution
Find the number of ways to run up n steps ChallengeSolution
Implement the Towers of Hanoi with 3 towers and N disks ChallengeSolution
Implement factorial recursively, dynamically, and iteratively ContributeContribute
Perform a binary search on a sorted array of integers ContributeContribute
Print all combinations of a string ContributeContribute
Implement a paint fill function ContributeContribute
Find all permutations to represent n cents, given 1, 5, 10, 25 cent coins ContributeContribute
Add a challenge ContributeContribute

Mathematics and Probability

Challenge Static Notebooks
Generate a list of primes ChallengeSolution
Find the digital root ChallengeSolution
Create a class supporting insert, max, min, mean, mode in O(1) ChallengeSolution
Determine if a number is a power of two ChallengeSolution
Add two numbers without the + or - sign ChallengeSolution
Subtract two numbers without the + or - sign ChallengeSolution
Check if a number is prime ContributeContribute
Determine if two lines on a Cartesian plane intersect ContributeContribute
Using only add, implement multiply, subtract, and divide for ints ContributeContribute
Find the kth number such that the only prime factors are 3, 5, and 7 ContributeContribute
Add a challenge ContributeContribute

Bit Manipulation

Challenge Static Notebooks
Implement common bit manipulation operations ChallengeSolution
Determine number of bits to flip to convert a into b ChallengeSolution
Draw a line on a screen ChallengeSolution
Flip a bit to maximize the longest sequence of 1s ChallengeSolution
Get the next largest and next smallest numbers ChallengeSolution
Merge two binary numbers ChallengeSolution
Swap odd and even bits in an integer ChallengeSolution
Print the binary representation of a number between 0 and 1 ChallengeSolution
Determine the number of 1s in the binary representation of a given integer ContributeContribute
Add a challenge ContributeContribute

Online Judges

Challenge Static Notebooks
Find the longest substring with at most k distinct chars ChallengeSolution
Find the highest product of three numbers ChallengeSolution
Maximize stocks profit from 1 buy and 1 sell ChallengeSolution
Move all zeroes in a list to the end ChallengeSolution
Find the products of every other int ChallengeSolution
Given a list of entries and exits, find the busiest period ChallengeSolution
Determine an island's perimeter ChallengeSolution
Format license keys ChallengeSolution
Find the longest absolute file path ChallengeSolution
Merge tuple ranges ChallengeSolution
Assign cookies ChallengeSolution
Determine if you can win in Nim ChallengeSolution
Check if a magazine could have been used to create a ransom note ChallengeSolution
Find the number of times a sentence can fit on a screen ChallengeSolution
Utopian tree ChallengeSolution
Maximizing xor ChallengeSolution
Add a challenge ContributeContribute

Repo Structure

interactive-coding-challenges        # Repo
 arrays_strings                    # Category of challenges
   rotation                       # Challenge folder
     rotation_challenge.ipynb    # Challenge notebook
     rotation_solution.ipynb     # Solution notebook            # Unit test*

*The notebooks (.ipynb) read/write the associated unit test (.py) file.

Notebook Installation

IPython Notebook

If you already have Python installed and are familiar with installing packages, you can get IPython Notebook with pip:

pip install "ipython[notebook]"

If you run into an issue about pyzmq, refer to the following Stack Overflow post and run:

pip uninstall ipython
pip install "ipython[all]"

As an alternative, you can also use the provided requirements.txt file:

pip install -r requirements.txt

For detailed instructions, scripts, and tools to more optimally set up your development environment, check out the dev-setup repo.

For more details on notebook installation, follow the directions here.

More information on IPython/Jupyter Notebooks can be found here.

Nose Tests

Install nose using setuptools/distribute:

easy_install nose


pip install nose

More information on Nose can be found here.

Running Challenges


Challenges are provided in the form of IPython/Jupyter Notebooks and have been tested with Python 2.7 and Python 3.x.

If you need to install IPython/Jupyter Notebook, see the Notebook Installation section.

  • This README contains links to nbviewer, which hosts static notebooks of the repo's contents
  • To interact with or to modify elements within the dynamic notebooks, refer to the instructions below

Run the notebook of challenges:

$ git clone
$ cd interactive-coding-challenges
$ jupyter notebook

This will launch your web browser with the list of challenge categories:

  • Navigate to the Challenge Notebook you wish to solve
  • Run the cells within the challenge notebook (Cell->Run All)
    • This will result in an expected unit test error
  • Solve the challenge and verify it passes the unit test
  • Check out the accompanying Solution Notebook for further discussion

To debug your solution with pdb, refer to the following ticket.

Note: If your solution is different from those listed in the Solution Notebook, consider submitting a pull request so others can benefit from your work. Review the Contributing Guidelines for details.

Future Development

Challenges, solutions, and unit tests are presented in the form of IPython/Jupyter Notebooks.

  • Notebooks currently contain mostly Python solutions (tested on both Python 2.7 and Python 3.x), but can be extended to include 40+ supported languages
  • Repo will be continually updated with new solutions and challenges
  • Contributions are welcome!


Contributions are welcome!

Review the Contributing Guidelines for details on how to:

  • Submit issues
  • Add solutions to existing challenges
  • Add new challenges




Contact Info

Feel free to contact me to discuss any issues, questions, or comments.

My contact info can be found on my GitHub page.


*I am providing code and resources in this repository to you under an open source license. Because this is my personal repository, the license you receive to my code and resources

interactive-coding-challenges open issues Ask a question     (View All Issues)
  • almost 3 years Add number prefix to directory names of categories/challenges to indicate order
  • over 3 years Add incremental hints for each challenge notebook
  • over 3 years Determine approach to add support for challenges in other languages
interactive-coding-challenges open pull requests (View All Pulls)
  • adds "reverse words in a string" challenge and its solution
  • add "remove specified character in a given string" challenge and its solution
  • Remove char challenge
  • Change `ipython notebook` to `jupyter notebook`
  • Replaced "range(len(..))"style iteration with "in"
  • Fixed issues with node state.
  • Fixed bug
  • Add a different solution to compress string challenge
  • Add two more test cases for string compress coding challenge.
  • fix_typos
  • Add new reverse word challenge
  • Set Solution: Find the single different char between two strings
  • Alternate flip_bit_challenge solution
  • Initial commit for new challenge: Non repeating char
  • Update: Compress c algorithm
  • Added __eq__ method to ensure invert_tree_challenge tests pass.
  • Update compress challenge with itertools.groupby() code
  • Remove specified characters in a string challenge
  • Update permutations challenge with empty strings test case
  • Include `Counter`-based permutation solution
  • Change longest common substring to subsequence
  • Added Dockerfile and docker-compose.yml
  • R2
  • Handled in a Single Function.
  • 1 liner solution for FizzBuzz problem
  • Fixed links of all questions.
  • proposed solution for add 2 integers with max bit length
  • Update ransom note solution to be more Pythonic
  • fixed misleading comment in node implementation
  • add test case for properly deleting the head node of a linked list
  • Refactor code
interactive-coding-challenges list of languages used
Other projects in Python