warming up your workspace

Python practice in Data Structures & Algorithms

Browse the rooms before signing in. Opening a room requires an account and follows your existing access. Practice does not issue certificates.

  • Contains Duplicate

    Before the fancy stuff: can you spot a repeat in one pass? Return whether any value appears more than once.

    hashing. Free room.

  • Maximum Subarray

    A trader wants the best contiguous run of daily gains and losses. Return the largest sum any contiguous slice produces (Kadane's algorithm).

    arrays. Free room.

  • The Single Number

    Every value appears twice except one. Find the loner in linear time and constant space, the famous XOR trick.

    bit-tricks. Free room.

  • Two Sum

    The classic warm-up every interview opens with: find the two numbers that add up to the target and return their indices.

    hashing. Free room.

  • Best Single Trade

    Buy low, sell high, once. Given a price series, return the maximum profit from one buy followed by one later sell.

    arrays. Account access required.

  • Longest Unique Window

    A network monitor wants the longest burst with no repeated packet id. Return the length of the longest substring without a repeating character.

    sliding-window. Account access required.

  • Move the Zeroes

    A buffer needs its empty slots pushed to the end without disturbing the order of the rest. Move all zeroes to the back, keeping the non-zeroes in place.

    two-pointers. Account access required.

  • Valid Parentheses

    A parser needs to know if the brackets balance. Use a stack to verify every opener has its matching closer in the right order.

    stacks. Account access required.

  • Binary Search

    A sorted index needs O(log n) lookups. Implement binary search, returning the position of the target or -1 if it is absent.

    binary-search. Account access required.

  • Group the Anagrams

    A dictionary tool clusters words that are rearrangements of each other. Return how many distinct anagram groups a word list forms.

    hashing. Account access required.

  • Merge Two Sorted Lists

    Two sorted runs need stitching into one. Merge them in lockstep into a single sorted list, the core of merge sort.

    linked-lists. Account access required.

  • Search Insert Position

    If the key is missing, where would it go? Return the index of the target, or the index where it should be inserted to keep the list sorted.

    binary-search. Account access required.

  • Count the Components

    A social graph has n people and a list of friendships. Count the connected components, the separate friend circles, with union-find.

    graphs. Account access required.

  • Count the Islands

    A satellite grid marks land as 1 and water as 0. Count the islands, the connected blobs of land joined horizontally or vertically.

    graphs. Account access required.

  • Kth Largest

    A leaderboard needs the kth-highest score without a full sort in mind. Return the kth largest element, the canonical heap problem.

    heaps. Account access required.

  • Most Frequent

    A trend tracker wants the single most common value, breaking ties toward the smaller one. Return it using a frequency map.

    hashing. Account access required.

  • Climb the Stairs

    A staircase of n steps can be taken one or two at a time. Count the distinct ways to reach the top, the gateway dynamic-programming problem.

    dynamic-programming. Account access required.

  • Coin Change

    A vending machine must make an amount with the fewest coins, or report it is impossible. Return the minimum coin count, or -1.

    dynamic-programming. Account access required.

  • House Robber

    A burglar cannot hit two adjacent houses. Return the maximum loot from a street of house values, no two consecutive.

    dynamic-programming. Account access required.

  • Longest Common Subsequence

    A diff tool measures how much two strings share in order. Return the length of their longest common subsequence with a DP table.

    dynamic-programming. Account access required.