Interactive Coding Challenges

repository·master·Indexed 12 days ago

https://github.com/donnemartin/interactive-coding-challenges

A collection of 120+ interactive, test-driven coding challenges designed for algorithm and data structure interview preparation. Delivered via Jupyter Notebooks and Anki flashcards, the resource includes reference implementations for core concepts like Linked Lists, Binary Search Trees, Graphs, and Dynamic Programming, as well as challenges covering Arrays, Strings, Bit Manipulation, and Mathematics.

Tokens
185.7K
Snippets
481
Records
539
Agent score
97%

What's inside Interactive Coding Challenges

  1. Overview of interactive-coding-challenges

    master
    The interactive-coding-challenges repository provides over 120 interactive, test-driven coding challenges focused on algorithms and data structures commonly found in technical interviews. Each challenge is presented via Jupyter Notebooks and includes reference solutions that are fully functional, unit-tested, and easy to understand. The project also provides reference implementations for various data structures and algorithms, as well as Anki flashcards for spaced repetition learning.
  2. How challenge notebooks are structured

    master

    Each challenge consists of two distinct notebooks designed to guide you through the learning process:

    1. Challenge Notebook (For Practice)

    This is where you solve the problem. It contains:

    • Problem Statement: The description of the task.
    • Constraints: Assumptions and limitations.
    • Test Cases: Descriptions of general and edge cases.
    • Algorithm: A placeholder section (refer to the solution notebook if stuck).
    • Hints: On-demand incremental hints (rolling out).
    • Code (Challenge: Implement Me!): Skeleton code for your implementation.
    • Unit Test: A test suite that is expected to fail until your implementation is correct.

    2. Solution Notebook (For Reference)

    This provides the answers and deep dives. It contains:

    • Algorithm: Detailed discussions of solutions including Big-O time and space complexities.
    • Code (Challenge: Implement Me!): One or more complete reference solutions.
    • Unit Test: The unit tests used to validate the reference solutions.
  3. Understand the repository structure

    master

    The repository is organized by data structure/algorithm categories. Each specific challenge is contained within its own folder following this pattern:

    category_name/
    └── challenge_name/
        ├── challenge_name_challenge.ipynb  # The interactive challenge
        ├── challenge_name_solution.ipynb  # The reference solution
        └── test_challenge_name.py          # The unit tests used by the notebook
    interactive-coding-challenges        # Repo
    ├─ arrays_strings                    # Category of challenges
    │  ├─ rotation                       # Challenge folder
    │  │  ├─ rotation_challenge.ipynb    # Challenge notebook
    │  │  ├─ rotation_solution.ipynb     # Solution notebook
    │  │  ├─ test_rotation.py            # Unit test
    │  ├─ compress
    │  │  ├─ compress_challenge.ipynb
    │  │  ├─ compress_solution.ipynb
    │  │  ├─ test_compress.py
    │  └─ ...
    ├─ linked_lists
    │  ├─ palindrome
    │  │  └─ ...
    │  └─ ...
    └─ ...
  4. Explore Bit Manipulation challenges

    master

    The repository provides a collection of interactive Jupyter Notebook challenges focused on bit manipulation. Each challenge includes a 'Challenge' notebook for implementation and a 'Solution' notebook for reference.

    Available bit manipulation challenges include:

    • Implement common bit manipulation operations
    • Determine number of bits to flip to convert a into b
    • Draw a line on a screen
    • Flip a bit to maximize the longest sequence of 1s
    • Get the next largest and next smallest numbers
    • Merge two binary numbers
    • Swap odd and even bits in an integer
    • Print the binary representation of a number between 0 and 1
  5. Access interactive coding challenges via Binder or Notebooks

    master

    You can interact with the coding challenges in two ways:

    1. Interactive Environment: Use the Binder link to launch a live, interactive Jupyter notebook environment in your browser.
    2. Static Notebooks: View individual challenges and their solutions as static notebooks using nbviewer.

    Each challenge typically follows a structured format within the notebook:

    • Problem Statement: Defines the task.
    • Constraints: Specifies limits (e.g., time/space complexity).
    • Test Cases: Provides inputs and expected outputs.
    • Algorithm/Hints: Offers guidance for implementation.
    • Code (Challenge: Implement Me!): The section where you write your solution.
    • Unit Test: A section to verify your implementation.
    https://mybinder.org/v2/gh/donnemartin/interactive-coding-challenges/master
  6. Explore Arrays and Strings challenges

    master

    The repository contains a collection of interactive coding challenges focused on Arrays and Strings. Each challenge is provided as a Jupyter Notebook with two versions: a Challenge notebook for practice and a Solution notebook for reference. You can run these interactively using Binder or view them as static notebooks via NBViewer.

    Available challenges include:

    • Determine if a string contains unique characters
    • Determine if a string is a permutation of another
    • Determine if a string is a rotation of another
    • Compress a string
    • Reverse characters in a string
    • Given two strings, find the single different char
    • Find two indices that sum to a specific value
    • Implement a hash table
    • Implement fizz buzz

    Some challenges (like 'Find the first non-repeated character in a string') are currently open for contribution.

    <!-- Example of how to access a challenge via NBViewer -->
    <a href="http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/arrays_strings/unique_chars/unique_chars_challenge.ipynb">Challenge</a> │ <a href="http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/arrays_strings/unique_chars/unique_chars_solution.ipynb">Solution</a>
  7. Explore Graphs and Trees challenges

    master

    The repository provides interactive challenges for Graphs and Trees, accessible via static notebooks. You can use Binder to run these notebooks interactively in your browser.

    Available challenges include:

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

    master

    The repository provides interactive Jupyter Notebook challenges for mastering Linked Lists. Similar to the Arrays and Strings section, each topic includes a Challenge notebook and a Solution notebook.

    Available challenges include:

    • Remove duplicates from a linked list
    • Find the kth to last element of a linked list
    • Delete a node in the middle of a linked list
    • Partition a linked list around a given value
    • Add two numbers whose digits are stored in a linked list
    • Find the start of a linked list loop
    • Determine if a linked list is a palindrome
    • Implement a linked list

    Challenges marked as 'Contribute' are available for community members to implement.

  9. Access Mathematics and Probability challenges

    master

    The repository includes a collection of challenges focused on mathematics and probability. These are also provided as Jupyter Notebooks via NBViewer, consisting of a Challenge notebook and a Solution notebook.

    Available challenges include:

    • Generating a list of primes
    • Finding the digital root
    • Creating a class for O(1) math operations (insert, max, min, mean, mode)
    • Determining if a number is a power of two
    • Adding/Subtracting numbers without using + or - operators