Practice Arena

Python Coding Challenges

Write real Python in the browser. Instant feedback. From beginner to expert.

577 challenges 370 easy 180 medium 27 hard
Python Basics easy

Set symmetric difference

Write a function that returns the elements found in exactly one of two sets, sorted ascending.

sets symmetric-difference sorting
+10 pts 15m
Python Basics easy

Remove Duplicates from Sorted Array

Given a sorted list, remove duplicates in-place and return the new length.

lists in-place two-pointers
+10 pts 15m
Strings & Text easy

Sort characters alphabetically

Sort all characters in a string alphabetically and return the sorted string.

sorting string manipulation
+5 pts 5m
Strings & Text easy

Sort characters in string

Write a function that sorts the characters in a string and returns the sorted string.

sorting string character
+8 pts 10m
Lists & Arrays easy

Remove duplicates (sorted)

Return a sorted list with duplicates removed.

arrays two-pointer
+10 pts 10m
Lists & Arrays easy

Merge two sorted arrays

Merge two sorted arrays into one sorted array.

arrays merge two-pointer
+12 pts 12m
Lists & Arrays medium

Merge intervals

Merge all overlapping intervals and return a sorted result.

intervals sort
+30 pts 26m
Lists & Arrays easy

Insert into a Sorted List

Implement a function that inserts a value into a sorted list at the correct position using binary search.

lists binary-search insertion
+10 pts 10m
Lists & Arrays easy

Intersection of Two Lists

Given two lists, return a sorted list of unique elements that appear in both lists.

intersection sorting unique
+10 pts 15m
Lists & Arrays easy

Merge Sorted Array In Place

Write a function that merges two sorted arrays into the first array in-place, keeping the result sorted.

arrays sorting in-place
+10 pts 15m
Lists & Arrays easy

Cartesian Product Pairs

Create a function that returns the Cartesian product of two lists as a sorted list of lists.

lists tuples sorting
+8 pts 12m
Dicts & Sets easy

List intersection

Return the sorted list of elements common to both lists.

sets intersection
+8 pts 8m
Dicts & Sets easy

Keys Sorted by Value Descending

Given a dictionary mapping strings to integers, return a list of keys sorted by value descending, and when values tie, alphabetically ascending.

sorting dictionaries ordering
+8 pts 10m
Dicts & Sets easy

Anagram Dictionary Groups Lite

Group a list of words into anagrams using a dictionary keyed by sorted characters.

dicts strings anagrams
+10 pts 15m
Dicts & Sets easy

Common Keys of Two Dictionaries

Implement a function that finds keys shared by two dictionaries and returns them sorted.

dict set sorting
+8 pts 10m
Dicts & Sets easy

Union of Many Sets

Implement a function that takes any number of sets and returns a sorted list of their union.

sets union flatten
+10 pts 10m
Dicts & Sets easy

Anagram Groups by Size

Group a list of words into anagram groups and return them sorted by group size and lexicographically.

dicts sets sorting
+10 pts 10m
Dicts & Sets easy

Top K Frequent Words

Given a list of words, return the k most frequent words sorted by frequency (descending) and then alphabetically.

dictionary sorting frequency
+10 pts 15m
Dicts & Sets easy

Symmetric Difference

Write a function that computes the symmetric difference of two lists, returning a sorted list of unique elements.

sets set-operations symmetric-difference
+8 pts 10m
Data Structures & Algorithms easy

Binary search

Return the index of target in a sorted list, or -1 if not present.

searching binary-search
+12 pts 12m
Data Structures & Algorithms medium

Quicksort

Implement quicksort and return a sorted list.

sorting recursion divide-and-conquer
+25 pts 25m
Data Structures & Algorithms medium

Longest Consecutive Sequence

Given an unsorted list of integers, find the length of the longest consecutive elements sequence in O(n) time.

hash set array linear
+20 pts 20m
Data Structures & Algorithms hard

Median of Two Sorted Arrays

Given two sorted arrays, return the median of the combined sorted array in O(log(min(n,m))) time.

median binary search arrays
+45 pts 40m
Data Structures & Algorithms medium

Merge Sort

Implement merge_sort(numbers) that returns a sorted copy of the input list using the merge sort algorithm.

sorting recursion divide-and-conquer
+30 pts 30m
Data Structures & Algorithms easy

Exponential Search

Implement exponential search to find any valid index of a target in a sorted list.

searching sorted-array algorithms
+10 pts 15m
Data Structures & Algorithms medium

K Closest Elements

Implement a function to return the k closest elements to a target in a sorted array.

arrays binary-search sorting
+25 pts 25m
Math & Number Theory easy

Sieve of Eratosthenes

Implement the Sieve of Eratosthenes to return a sorted list of all primes up to a given integer n.

primes sieve loops
+10 pts 15m
Math & Number Theory easy

Prime Factorization

Return a sorted list of prime factors of a positive integer, including repeated factors.

prime math loops
+10 pts 15m
Dynamic Programming easy

Shortest Unsorted Continuous Subarray

Given an array of integers, return the length of the shortest contiguous subarray whose sorting makes the whole array sorted.

arrays sorting two-pointers
+10 pts 15m
Graphs & Graph Algorithms medium

Alien Dictionary Order

Given a sorted list of words in an alien language, derive the order of its unique letters.

graph topological-sort string
+30 pts 30m
Greedy Algorithms hard

Patching Array

Given a sorted array of positive integers and a target n, find the minimum number of patches to make every number from 1 to n representable as a subset sum.

greedy arrays prefix-sums
+40 pts 30m
Binary Search medium

Search in Rotated Array

Implement an efficient search in a rotated sorted array using modified binary search.

binary-search arrays search
+20 pts 20m
Binary Search medium

Interpolation Search

Implement interpolation search in Python on a sorted list of integers.

search sorted-array binary-search
+25 pts 25m
Binary Search easy

Search Insert Position

Return the index where a target should be inserted into a sorted list to maintain order.

binary-search arrays searching
+10 pts 15m
Binary Search medium

Find Minimum in Rotated Sorted Array

Implement a function that finds the minimum element in a rotated sorted array of distinct integers in O(log n) time.

binary-search arrays rotation
+25 pts 30m
Binary Search hard

Median of Sorted Array BS

Implement a binary search algorithm to find the median of two sorted arrays efficiently.

binary-search arrays median
+45 pts 35m
Binary Search medium

Single Element in Sorted Array

Given a sorted array where every element appears exactly twice except one which appears once, return the single element.

binary-search array xor
+20 pts 25m
Binary Search easy

Upper Bound Binary Search

Write a function that returns the index of the first element greater than a target in a sorted list.

binary-search arrays searching
+8 pts 12m
Binary Search easy

Find Indices of Target in Sorted List

Given a sorted list and a target, return the indices of its first and last occurrence, or [-1, -1] if absent.

binary-search sorted range
+10 pts 10m
Binary Search medium

Rotated Array Search II

Implement a function to search for a target in a rotated sorted array with possible duplicates.

binary-search array search
+20 pts 20m
Binary Search hard

Kth Smallest in Sorted Matrix

Implement kth_smallest(matrix, k) to return the kth smallest element in a row- and column-sorted square matrix.

matrix binary-search heap
+40 pts 35m
Two Pointers & Sliding Window easy

Two Sum Sorted

Given a 1-indexed sorted array and a target, return the two indices that add up to the target.

two-pointers sorted-array array
+10 pts 15m
Two Pointers & Sliding Window easy

Squares of Sorted Array

Implement a function that returns a sorted list of squares for a given non-decreasing integer array.

two-pointers sorting array
+10 pts 15m
Two Pointers & Sliding Window medium

Interval List Intersections

Given two lists of sorted, disjoint intervals, return the list of intersections between them.

two-pointers intervals merging
+20 pts 20m
Stacks & Queues medium

Buildings with ocean view

Given building heights, return sorted indices of buildings that have a clear view of the ocean to their right.

stack monotonic-stack arrays
+20 pts 20m
Heaps & Priority Queues medium

Kth Largest Element in an Array (Heap Edition)

Implement a function that returns the kth largest element in an unsorted integer array using a heap.

heap priority-queue array
+20 pts 25m
Heaps & Priority Queues medium

Find K pairs with smallest sums

Given two sorted arrays and an integer k, return the k smallest pairs (u, v) with the smallest sums, sorted by sum.

heap priority queue two-sum
+25 pts 30m

Showing 47 challenges

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

  1. Pick a category — basics, algorithms, strings, and more
  2. Open a challenge, read the statement, and edit the starter code
  3. 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.