Fibonacci(n)
Return the nth Fibonacci number efficiently.
Additive number sequence
Check whether a given digit string can be partitioned into a valid additive sequence where each term is the sum of the previous two.
Find Duplicate Number
Given a list of n+1 integers in the range 1..n, find the one integer that appears more than once.
Two Missing Numbers
Given a list of n-2 unique integers from 1 to n, find the two missing numbers efficiently.
Three Missing Numbers
Find the three missing numbers from a shuffled list containing all but three integers from 1 to n.
Count Smaller Numbers
Given an integer list, return for each position how many later elements are smaller than it.
Subarray sum equals K
Count the number of contiguous subarrays whose sum equals k.
Complex Number Class
Implement a Complex class supporting addition, subtraction, multiplication, division, equality, and string formatting.
Coin change (DP)
Find the minimum number of coins to make exactly the target amount.
Count inversions lite
Implement a function that counts inversions in a list of numbers efficiently.
Merge Sort
Implement merge_sort(numbers) that returns a sorted copy of the input list using the merge sort algorithm.
Bucket Sort
Implement bucket sort to sort a list of floating-point numbers in the range [0,1).
Decode Ways
Count the number of ways to decode a numeric string into letters using the mapping A=1 to Z=26.
Online Stock Span
Implement StockSpanner.next(price) that returns the maximum number of consecutive days (including today) with price <= current price.
Eulerian Path Check
Given the number of vertices and an edge list of an undirected graph, decide if it has an Eulerian path.
Strobogrammatic number II
Given a positive integer n, return all strobogrammatic numbers of length n in ascending order.
Multiprocessing Queue
Implement a function that uses a multiprocessing queue to compute factorials of a list of numbers in parallel.
Prime Sieve Generator
Implement a generator function that yields prime numbers from 2 up to a specified limit, using an efficient sieve approach.
LRU Memoize
Implement an LRU memoization decorator that caches results for a fixed number of arguments.
Rate Limit Decorator
Implement a decorator that enforces a maximum number of calls per second for any function.
Match Credit Card Pattern
Write a function that validates a credit card number string against a set of formatting rules.
Smith Number Check
Write a function to check if a number is a Smith number by comparing digit sums of the number and its prime factorization.
Extended Euclidean Algorithm
Implement the extended Euclidean algorithm to return (gcd, x, y) such that ax + by = gcd(a, b).
Correlation Coefficient
Write a pure-Python function that computes the Pearson correlation coefficient between two lists of numbers.
Bitwise AND of a Range
Given a range [a, b], return the bitwise AND of all integers in that inclusive range without iterating over all numbers.
Maximum XOR Pair
Implement max_xor_pair(nums) that returns the maximum XOR value obtainable by pairing any two numbers in the given list.
Bell number
Implement a function to compute the Bell number B(n) using dynamic programming.
Edit Distance (Levenshtein Distance)
Implement the classic edit distance algorithm to find the minimum number of single-character edits required to transform one string into another.
Target Sum Subsets
Write a function that counts the number of subsets of a list of positive integers that sum exactly to a target.
Coin Change Minimum
Given coin denominations and a target amount, compute the minimum number of coins needed or -1 if impossible.
Coin Change Ways
Count the number of distinct combinations of coins that sum to a target amount.
Perfect Squares Sum
Given a positive integer n, return the least number of perfect squares (e.g., 1, 4, 9, 16, ...) that sum to n.
Ugly Number II
Given an integer n, return the nth ugly number using an efficient dynamic programming approach.
Target sum assignments
Given a list of integers and a target, count how many ways to assign + or - to each number so the total equals the target.
Delete and Earn
Given an array of integers, find the maximum points you can earn by repeatedly deleting a number and all its adjacent values.
Sum Root to Leaf Numbers
Given the root of a binary tree, compute the total sum of all root-to-leaf numbers.
Maximum Width of a Binary Tree
Given the root of a binary tree, compute its maximum width (the maximum number of nodes in any level, counting null positions).
Open the Lock BFS
Implement a BFS solution to find the minimum number of turns needed to open a 4-wheel lock, avoiding a set of deadends.
Minimum Genetic Mutation
Implement a function to compute the minimum number of single-character mutations needed to transform one gene string into another, using a given bank of valid mutations.
Graph Coloring Backtrack
Given an adjacency list and a number of colors, decide if the graph can be colored so no adjacent vertices share a color.
Android unlock patterns
Count the number of valid Android unlock patterns of a given length using a 3x3 grid with adjacency constraints.
Most stones removed
Given stone coordinates on a grid, find the maximum number of stones that can be removed while every stone shares a row or column with another remaining stone.
Letter Combinations of a Phone Number
Given a string of digits, return all possible letter combinations that the number could represent on a phone keypad.
N-Queens Count
Count the number of distinct valid placements of n non-attacking queens on an n×n chessboard.
Letter Tile Possibilities
Given a string of letter tiles, count the number of distinct non-empty sequences that can be formed using any non-empty subset in any order.
Beautiful Arrangement Count
Count the number of permutations of 1..n such that for every index i, either i is divisible by the number at that position or the number is divisible by i.
Rat in a Maze
Count the number of distinct paths a rat can take from top-left to bottom-right in a binary grid, moving down or right and avoiding walls.
Meeting Rooms Minimum
Given a list of meeting time intervals, compute the minimum number of conference rooms required.
Boats to Save People
Given a list of people weights and a boat's weight limit, return the minimum number of boats required.
Minimum Number of Arrows to Burst Balloons
Given balloon intervals, find the minimum number of arrows to burst all balloons by merging overlaps.
Queue Reconstruction by Height
Given shuffled pairs of (height, number_of_taller_people_in_front), reconstruct the original queue order.
Non-overlapping Intervals
Given a list of intervals, return the minimum number of intervals to remove to make the rest non-overlapping.
Max events attended
Given a list of events with start and end times, find the maximum number of non-overlapping events you can attend.
Nth Magical Number
Given three integers n, a, b, return the nth positive integer that is divisible by either a or b.
Minimum Limit of Balls in a Bag
Given an array of bag sizes and a number of allowed splits, find the minimum possible maximum bag size.
Character Replacement Window
Given a string and a number k, find the length of the longest substring that can be made uniform by replacing at most k characters.
Count Nice Subarrays
Given an array of integers, count the number of contiguous subarrays that contain exactly k odd numbers.
Closest Three Sum
Given an array of integers and a target, return the sum of three numbers that is closest to the target.
Fruit into Baskets
Given an array of integers representing fruit types, return the maximum number of fruits you can collect in a contiguous subarray with at most two distinct types.
Binary Subarray with Sum
Given a binary list and a goal sum, count the number of subarrays that add up to that goal.
Boats to Save People – Two Pointer
Implement a function that returns the minimum number of boats needed to rescue everyone, given a weight limit and each boat carrying at most two people.
Count Nice Subarrays
Count subarrays that contain exactly k odd numbers.
Remove K Digits Stack
Remove k digits from a non-negative integer string to produce the smallest possible number using a stack-based approach.
Top K Frequent Elements
Given an integer array and a number k, return the k most frequent elements using a heap-based approach.
Top K Frequent Elements
Given a list of integers and a number k, return the k most frequent elements in descending order of frequency, with ties broken by larger value.
Task Scheduler Heap
Given a list of tasks and a cooldown, find the minimum number of CPU intervals needed to schedule all tasks without violating the cooldown.
Meeting Rooms II with Heaps
Given a list of meeting intervals, compute the minimum number of rooms required using a heap-based approach.
Number of Islands
Given a 2D grid of '1' (land) and '0' (water), count the number of islands surrounded by water.
Number of Islands in a Matrix
Count the number of distinct islands (connected groups of 1s) in a 2D binary matrix.
Regions Cut by Slashes
Given a grid of slashes, count the number of connected regions formed by the slashes and the grid borders.
Julian Day Number Converter
Implement two functions to convert between Gregorian calendar dates and Julian Day Numbers using a standard formula.
Extract JSON-like numbers
Parse a simplified JSON-like string without using the json module and sum all numbers found in it.
Showing 72 challenges · medium
Guide: free Python coding challenges
Practice Python by solving problems
PythonSkillset challenges are hands-on coding exercises from beginner to advanced. Open a challenge, read the problem, write Python in the split-pane editor, and run tests with Pyodide — no install required.
How to use the arena
- Pick a category — basics, algorithms, strings, and more
- Open a challenge, read the statement, and edit the starter code
- Run tests, fix failures, then try a related quiz or tutorial lesson
Challenges vs tutorials and quizzes
Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.