Practice Arena

Python Coding Challenges

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

467 challenges 330 easy 120 medium 17 hard
Python Basics easy

FizzBuzz, precisely

Return a newline-separated string for 1..n: Fizz, Buzz, FizzBuzz, or the number.

control flow strings modulo
2
+10 pts 12m
Python Basics easy

Temperature converter

Convert Celsius to Fahrenheit: F = C × 9/5 + 32.

arithmetic floats
2
+5 pts 5m
Python Basics easy

Even or odd?

Return 'even' or 'odd' for an integer.

modulo conditionals
1
+5 pts 5m
Python Basics easy

Sum of digits

Return the sum of all decimal digits of a non-negative integer.

arithmetic loops
2
+8 pts 10m
Python Basics easy

Collatz steps

Count how many steps the Collatz sequence takes to reach 1 from n.

loops math
1
+10 pts 12m
Python Basics easy

Factorial (iterative)

Compute n! iteratively without recursion.

loops math
+8 pts 8m
Python Basics easy

Power of two?

Return True if n is an exact power of 2.

bitwise math
+8 pts 8m
Python Basics easy

GCD via Euclid

Compute the greatest common divisor of two positive integers.

math recursion
+10 pts 10m
Python Basics easy

Prime checker

Return True if n is a prime number.

math loops
1
+10 pts 10m
Python Basics easy

Compound interest

Return the future balance after compound interest, rounded to two decimals.

math functions finance
+12 pts 12m
Python Basics easy

Clamp a Number to a Range

Implement a clamp function that returns a value within a specified range.

numbers conditionals comparisons
+5 pts 5m
Python Basics easy

Absolute Difference of Two Integers

Compute the absolute difference between two integers, regardless of order.

absolute difference math
+5 pts 5m
Python Basics easy

Leap Year Checker

Implement a function that decides whether a year is a leap year according to the standard Gregorian rules.

boolean conditionals date
+5 pts 5m
Python Basics easy

Grade from Score

Write a function that maps a numeric score to its letter grade using standard grading thresholds.

conditionals functions integers
+8 pts 10m
Python Basics easy

Min of three numbers

Write a function that returns the minimum of three integers.

min comparison function
+5 pts 5m
Python Basics easy

Integer division and remainder

Write a function that performs integer division and returns both quotient and remainder.

operators division remainder
+8 pts 10m
Python Basics easy

Count down from n

Implement a function that returns a list from n down to 1.

loops range lists
+5 pts 5m
Python Basics easy

Sum numbers from 1 to n

Implement a function that computes the sum of all integers from 1 to n.

sum loop arithmetic
+5 pts 5m
Python Basics easy

Multiplication Table Row

Return the nth row of a multiplication table as a list of 1..n products.

loops lists multiplication
+5 pts 5m
Python Basics easy

Sign of a Number

Write a function that returns the sign of a number as a string.

conditionals numbers comparison
+5 pts 5m
Python Basics easy

Seconds to Hours Minutes Seconds

Convert total seconds into a zero-padded HH:MM:SS format.

arithmetic divmod formatting
+8 pts 10m
Python Basics easy

Is a multiple of both

Write a function that returns True if a number is divisible by both of two given divisors.

modulo boolean function
+5 pts 5m
Python Basics easy

Digit count of an integer

Given an integer, return the number of digits it has, handling negatives and zero correctly.

integers loops arithmetic
+5 pts 5m
Python Basics easy

Boolean from comparison chain

Implement a function that evaluates a chain of comparisons and returns the boolean result.

comparison booleans evaluation
+8 pts 10m
Python Basics easy

Max of a variable-length list

Implement a function that returns the maximum value from a list of numbers without using max().

conditionals loops comparison
+10 pts 10m
Python Basics easy

Classify triangle by sides

Write a function that classifies a triangle based on three side lengths.

conditionals geometry validation
+8 pts 10m
Python Basics easy

Toggle a boolean n times

Apply boolean toggling n times and return the final boolean value.

booleans arithmetic modulo
+6 pts 8m
Python Basics easy

Between inclusive

Write a function that returns True if a number is between two given bounds, inclusive of the bounds.

comparison conditionals boundaries
+8 pts 10m
Python Basics easy

Last Occurrence of a Value

Implement a function that returns the last index of a given value in a list, or -1 if it's not present.

lists search indexing
+10 pts 15m
Python Basics easy

Cycle a List Once

Implement a function that rotates a list right by one position.

lists rotation indexing
+5 pts 5m
Python Basics easy

Boolean Mask Filter

Write a function that filters a list based on a boolean mask and returns the selected elements.

filter boolean lists
+10 pts 15m
Python Basics easy

Replace negatives with zero

Implement a function that replaces all negative numbers in a list with zero.

lists loops conditionals
+10 pts 10m
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

Swap Two Values

Implement a Python function that swaps two given values and returns them in swapped order.

variables assignment swap
+5 pts 5m
Python Basics easy

Count Multiples in a Range

Given a start, end, and divisor, count how many integers in [start, end] are divisible by the divisor.

multiples range divisibility
+10 pts 10m
Python Basics easy

Hello, name!

Implement a function that returns a personalized greeting for a given name.

strings function formatting
+5 pts 5m
Python Basics easy

Leap Year Checker

Implement a function that returns True if a year is a leap year according to the Gregorian calendar rules.

conditionals boolean modulo
+10 pts 10m
Python Basics easy

Grade Calculator

Implement a function that converts a numeric score to a letter grade using a standard scale.

conditionals functions basic-syntax
+8 pts 10m
Python Basics easy

Minutes to Hours: Time Conversion Helper

Write a function that converts minutes into a human-readable 'Xh Ym' string, with special cases for zero and whole hours.

arithmetic formatting conditionals
+8 pts 10m
Python Basics easy

Simple Interest Calculator

Implement a function that calculates simple interest given principal, annual rate, and time in years.

arithmetic floats basics
+5 pts 5m
Python Basics easy

Tip Calculator

Write a function that calculates the total bill after adding a given tip percentage.

arithmetic rounding basics
+8 pts 10m
Python Basics easy

Absolute Difference

Implement a function that returns the absolute difference between two numbers.

absolute value arithmetic function
+5 pts 5m
Python Basics easy

Max of three numbers

Implement a function that returns the maximum of three numbers using comparisons.

conditionals comparison numbers
+10 pts 10m
Python Basics easy

Sign of a number

Write a function sign_of_number that returns -1 for negatives, 0 for zero, and 1 for positives.

conditionals numbers comparison
+5 pts 5m
Python Basics easy

Countdown printer

Implement a function that prints a countdown from a given number down to 1, then returns 'Go!'.

loops conditionals function-definition
+5 pts 5m
Python Basics easy

Sum from 1 to n

Write a function that returns the sum of all integers from 1 to n (inclusive).

math arithmetic sum
+5 pts 5m
Python Basics easy

Average of a list

Write a function that computes the average of a list of numbers, handling empty lists by returning 0.

average list statistics
+5 pts 5m
Python Basics easy

Count Positives

Count the positive numbers in a list of integers.

conditionals loops basic
+10 pts 10m
Python Basics easy

Find Minimum Value

Write a function that returns the minimum integer from a given list.

min list loop
+10 pts 10m
Python Basics easy

Range of values

Calculate the range (max minus min) of a list of numbers. Empty list returns 0.

min max numbers
+10 pts 10m
Python Basics easy

Is divisible by?

Create a function that returns True if a is divisible by b with no remainder, with a clear definition of edge cases.

division modulo conditionals
+10 pts 10m
Python Basics easy

Round to nearest ten

Write a function that rounds any integer to the nearest multiple of ten.

arithmetic rounding integers
+8 pts 10m
Python Basics easy

Fahrenheit to Celsius

Implement a function that converts degrees Fahrenheit to degrees Celsius.

temperature arithmetic conversion
+5 pts 5m
Python Basics easy

Speed Converter

Write a function to convert speeds between kilometers per hour and meters per second.

arithmetic conversion function
+5 pts 5m
Python Basics easy

Area of Rectangle

Write a function that returns the area of a rectangle given its width and height.

arithmetic function numbers
+5 pts 5m
Python Basics easy

Perimeter of triangle

Given three side lengths, return the perimeter (sum) of the triangle.

arithmetic geometry basics
+5 pts 5m
Python Basics easy

Circle Circumference Calculator

Implement a function that computes the circumference of a circle from its radius using the formula 2πr.

math function basics
+10 pts 10m
Python Basics easy

Volume of Cube

Write a Python function that returns the volume of a cube given its side length.

arithmetic return function
+5 pts 5m
Python Basics easy

Modulo Remainder

Implement a function that returns the remainder of a divided by b without using the modulo operator.

modulo arithmetic integers
+5 pts 5m
Python Basics easy

Print Pyramid Pattern

Implement a function that returns a centered asterisk pyramid as a list of strings.

loops strings pattern-printing
+10 pts 15m
Python Basics easy

Digit Count

Count the number of digits in an integer using arithmetic, without string conversion.

numbers loops math
+8 pts 12m
Python Basics easy

Last Digit Extractor

Write a function that returns the last digit of a non-negative integer using the modulo operator.

integers modulo arithmetic
+5 pts 5m
Python Basics easy

Count word occurrences

Write a function that takes a sentence and returns a dictionary of word counts.

strings counting dictionaries
+10 pts 15m
Python Basics easy

Find Missing Number

Given a list of n distinct integers from 0..n with one missing, return the missing number.

math integers arrays
+10 pts 10m
Python Basics easy

Map, Filter, Reduce

Implement three functions using map, filter, and reduce to manipulate a list of integers.

map filter reduce
+10 pts 15m
Python Basics easy

Variadic Sum Function

Implement a variadic function that sums an arbitrary number of numeric arguments.

functions args sum
+10 pts 10m
Python Basics easy

Linear Search Implementation

Implement a linear search function that returns the index of the first occurrence of a target in a list, or -1 if not found.

linear-search list index
+10 pts 15m
Python Basics easy

Pathlib Operations: File Path Basics

Practice using pathlib to manipulate file paths and extract components.

pathlib file-paths strings
+8 pts 10m
Python Basics easy

Garbage Collection Hint

Write a function that predicts when an object is garbage collected based on reference counting.

garbage-collection reference-counting object-lifecycle
+10 pts 10m
Python Basics easy

Enumerate with start

Implement a function that mimics Python's enumerate with a custom start index.

enumerate loops tuples
+5 pts 5m
Python Basics easy

Validate date format

Return True if input string is exactly YYYY-MM-DD and a real calendar date.

validation strings dates
+10 pts 10m
Python Basics easy

Palindromic Number Check

Write a function to check if a given integer is a palindrome.

numbers strings conditionals
+10 pts 10m
Python Basics easy

Hexagonal Number

Write a function to check if a positive integer is a hexagonal number.

math loops conditionals
+10 pts 15m
Python Basics easy

Count trailing zeros

Write a function that counts the number of trailing zeros in the decimal representation of a positive integer.

loops integers basics
+5 pts 5m
Python Basics easy

Count Leading Zeros

Write a function that returns the number of leading zeros in a list of integers.

lists iteration counting
+8 pts 8m
Strings & Text easy

Reverse a string

Return the characters of the string in reverse order.

strings slicing
+5 pts 5m
Strings & Text easy

Palindrome check

Return True if the string reads the same forwards and backwards (ignoring case and non-alphanumeric).

strings two-pointer
+8 pts 8m
Strings & Text easy

Count vowels

Count the number of vowels (a, e, i, o, u) in a string (case-insensitive).

strings counting
+5 pts 5m
Strings & Text easy

Title case converter

Return the string with each word capitalised.

strings split
+5 pts 5m
Strings & Text easy

Anagram check

Return True if two strings are anagrams of each other.

strings sorting counter
+10 pts 10m
Strings & Text easy

Strip and Collapse Whitespace

Write a function that strips leading/trailing whitespace and collapses inner runs of whitespace to single spaces.

strings whitespace normalization
+10 pts 15m
Strings & Text easy

Snake case to camel case

Implement a function that converts snake_case strings to camelCase.

strings case-conversion text-processing
+10 pts 10m
Strings & Text easy

Camel case to snake case

Write a function that converts camelCase input to snake_case while handling acronyms and numbers correctly.

strings case-conversion parsing
+10 pts 15m
Strings & Text easy

Remove punctuation

Write a function that removes all ASCII punctuation characters from a string.

strings punctuation cleaning
+10 pts 10m
Strings & Text easy

Is pangram

Write a function that determines whether a given string is a pangram, ignoring case and non-letter characters.

strings sets algorithm
+8 pts 12m
Strings & Text easy

Caesar Cipher Shift

Implement a function to apply a Caesar cipher shift to a string, preserving case and ignoring non-letters.

strings ascii cipher
+10 pts 15m
Strings & Text easy

Repeat each character n times

Given a string s and an integer n, return a new string where each character of s is repeated n times consecutively.

strings join comprehension
+8 pts 10m
Strings & Text easy

Longest word in a sentence

Write a function that returns the longest word from a sentence, with first-occurrence tie-breaking.

strings parsing split
+8 pts 10m
Strings & Text easy

Replace vowels with stars

Write a function that replaces every vowel in a given string with an asterisk.

strings transformation vowels
+10 pts 10m
Strings & Text easy

Is isogram

Implement a function that determines whether a string is an isogram (no repeated letters, case-insensitive).

strings case-insensitive validation
+10 pts 10m
Strings & Text easy

Extract Digits Only

Given a string that may contain letters, symbols, and whitespace, extract all digits in order and return them as an integer.

strings digits parsing
+5 pts 5m
Strings & Text easy

Kebab Case a Phrase

Implement a function that converts a phrase into lowercase kebab-case, handling spaces, punctuation, and camelCase.

strings case-conversion regex
+10 pts 15m
Strings & Text easy

Normalize quotes

Replace all typographic quote characters with straight ASCII quotes.

strings replacement unicode
+10 pts 12m
Strings & Text easy

Find all indexes of a substring

Write a function that returns a list of all starting indexes where a substring appears in a string, including overlapping occurrences.

substring string searching
+10 pts 15m
Strings & Text easy

Remove Consecutive Duplicate Letters

Implement a function that removes consecutive duplicate letters from a string, keeping only one occurrence of each run.

strings loops manipulation
+10 pts 15m
Strings & Text easy

Interleave Two Strings

Given two strings s1 and s2, return a new string that interleaves them character by character, starting with s1.

strings merging loops
+8 pts 10m
Strings & Text easy

Is rotation of another string

Write a function to determine if one string is a rotation of another string.

strings rotation membership
+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

Initials from a Full Name

Return the uppercase initials of each word in a given full name.

strings splitting uppercase
+8 pts 10m
Strings & Text easy

Count words in a sentence

Implement a function to count words in a sentence, ignoring extra whitespace and handling empty strings.

strings split counting
+10 pts 10m
Strings & Text easy

Center a string in a width

Write a function that centers a string within a specified width by adding spaces on both sides.

strings padding formatting
+8 pts 10m
Strings & Text easy

Caesar Cipher Shift

Write a function that shifts letters in a string by a given amount, preserving case and ignoring non-letters.

caesar string cipher
+8 pts 10m
Strings & Text easy

Reverse Words in a Sentence

Reverse the order of words in a sentence while preserving single spaces between words.

strings split reverse
+10 pts 15m
Strings & Text easy

Count consonants

Write a function that counts the number of consonant letters in a string.

strings counting loops
+10 pts 10m
Strings & Text easy

Is pangram?

Implement is_pangram(s) to return True if the string contains every letter from 'a' to 'z' at least once, ignoring case and non-alphabetic characters.

strings set validation
+8 pts 10m
Strings & Text easy

Remove Duplicates from String

Given a string, return a new string with each character that repeats consecutively reduced to a single occurrence.

strings loop filter
+8 pts 10m
Strings & Text easy

Longest Word Finder

Write a function that extracts alphabetic words from a string and returns the longest one, with ties broken by earliest position.

strings parsing max
+10 pts 10m
Strings & Text easy

Abbreviate Name

Create a function that takes a full name and returns an abbreviated version with initials and the last name.

strings formatting split
+10 pts 15m
Strings & Text easy

Mask email address

Given an email address, return a masked version that hides everything but the first and last character of the local part and the domain.

strings masking validation
+8 pts 10m
Strings & Text easy

Extract digits from string

Write a function that extracts all digit characters from a given string, preserving their original order.

strings digits parsing
+6 pts 8m
Strings & Text easy

Replace Spaces with Dashes

Write a function that replaces every space in a string with a dash.

strings replace manipulation
+5 pts 5m
Strings & Text easy

Capitalize First Letter

Write a function that capitalizes the first letter of each word in a string.

string capitalization title
+8 pts 10m
Strings & Text easy

Snake case converter

Implement a function that converts a string to snake_case according to given rules.

strings snake_case formatting
+10 pts 15m
Strings & Text easy

Camel Case Converter

Write a function that converts a space-separated phrase into lower camelCase.

strings casing manipulation
+8 pts 10m
Strings & Text easy

Kebab Case Converter

Implement a function that converts any string to kebab-case, handling spaces, underscores, camelCase, and punctuation.

strings case-conversion parsing
+8 pts 15m
Strings & Text easy

Count Syllables (Simple)

Count syllables in a word by counting groups of consecutive vowels (a, e, i, o, u).

strings vowels counting
+10 pts 15m
Strings & Text easy

Is isogram?

Write a function that checks whether a given word is an isogram, ignoring letter case and only considering alphabetic characters.

strings case-insensitive set
+8 pts 12m
Strings & Text easy

Rotate String Right

Implement a function that rotates a given string to the right by a specified number of positions, handling shifts larger than the string length.

strings rotation slicing
+8 pts 10m
Strings & Text easy

Compress Consecutive Chars

Write a function that compresses a string by replacing runs of identical characters with the character followed by the count.

string run-length compression
+8 pts 12m
Strings & Text easy

Expand compressed string

Implement a function that expands run-length encoded strings (e.g., 'a3b2' → 'aaabb').

strings parsing run-length-encoding
+10 pts 15m
Strings & Text easy

Find substring index

Implement a function that returns the starting index of the first occurrence of a substring using only basic string indexing and slicing.

string search index
+10 pts 15m
Strings & Text easy

Count Substrings

Implement a function that counts non-overlapping occurrences of a substring in a given string.

strings counting substrings
+10 pts 15m
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
Strings & Text easy

Most Common Character

Return the character that appears most frequently in a string, breaking ties by earliest occurrence.

strings counting dictionary
+10 pts 15m
Strings & Text easy

Roman to Integer

Convert a valid Roman numeral string to an integer using standard rules.

roman string integer
+10 pts 15m
Strings & Text easy

Isomorphic Strings Check

Given two strings, check if they are isomorphic by verifying a one-to-one character mapping.

strings mapping hash-map
+10 pts 15m
Strings & Text easy

Index of First Occurrence

Implement a function that finds the starting index of a substring within a string, returning -1 when absent.

strings search index
+8 pts 12m
Strings & Text easy

Safe Command Executor

Implement emulate_run that simulates running a command list and returns output and exit code.

string-parsing simulation lists
+8 pts 10m
Strings & Text easy

Error message formatter

Write a function that constructs a formatted error message from a code, an optional context, and a fallback message.

formatting strings function
+10 pts 15m
Strings & Text easy

Stack Trace Sanitizer

Implement a function that rewrites traceback file paths to basenames only.

strings regex parsing
+8 pts 12m
Strings & Text easy

Extract Hashtags

Extract unique hashtags from a given text string in the order they appear.

strings parsing hashtags
+10 pts 15m
Strings & Text easy

Extract mentions

Extract unique @mentions from a string, respecting email-like patterns and punctuation.

strings parsing sets
+10 pts 15m
Strings & Text easy

Validate time format

Check whether a given string is a valid 24-hour time in HH:MM format.

strings validation time
+10 pts 15m
Strings & Text easy

Parse Log Line

Write a function that parses a log line and returns a dictionary with timestamp, level, and message.

string-parsing split strip
+10 pts 15m
Strings & Text easy

Replace multiple spaces

Implement a function that replaces every sequence of spaces with a single space.

strings whitespace normalization
+8 pts 10m
Strings & Text easy

Remove HTML tags

Remove all HTML tags from a string to extract clean text.

html string parsing
+10 pts 15m
Strings & Text easy

Extract Quoted Strings

Write a function that extracts the text inside every double-quoted substring from a given string.

strings parsing quotes
+8 pts 12m
Strings & Text easy

Split on camelCase

Given a camelCase string, split it into words at uppercase letters and return them as lowercase words.

strings parsing camelcase
+8 pts 10m
Strings & Text easy

Extract domain from URL

Extract the domain (hostname without port or www) from a given URL string.

url parsing strings
+8 pts 12m
Strings & Text easy

Normalize Whitespace

Write a function that normalizes any whitespace in a string to single spaces and trims the ends.

strings whitespace split-join
+5 pts 10m
Strings & Text easy

Strip Leading Zeros

Write a function that strips leading zeros from a string representing a non-negative integer.

strings strip lstrip
+5 pts 5m
Strings & Text easy

Parse key=value pairs

Implement a parser that converts a space-separated 'key=value' string into a Python dictionary, supporting quoted values.

parsing strings dictionaries
+8 pts 10m
Strings & Text easy

Find all numbers in text

Write a function that extracts all standalone integers from a text string using regular expressions.

regex parsing numbers
+8 pts 12m
Strings & Text easy

Extract file extensions

Implement a function that extracts the extension from a filename according to standard rules.

strings parsing file-paths
+8 pts 10m
Strings & Text easy

Validate username format

Implement a function that validates a username according to length, allowed characters, and no consecutive underscores.

strings validation returns
+8 pts 12m
Strings & Text easy

Replace template variables

Implement a function that replaces {{variable}} placeholders in a string using a dictionary, leaving unknown placeholders intact.

string-manipulation parsing template
+10 pts 15m
Strings & Text easy

Hamming Distance

Implement a function that computes the Hamming distance between two strings of equal length.

strings character-comparison distance
+10 pts 15m
Lists & Arrays easy

Two Sum

Return indices (i, j) with i < j such that nums[i] + nums[j] == target.

dict complement
+18 pts 16m
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 easy

Running Product of Integers

Given a list of integers, return a new list where each element at index i is the product of all elements from index 0 to i.

prefix product lists
+10 pts 10m
Lists & Arrays easy

Second Largest Unique Value

Return the second largest distinct integer from a list, or None if it doesn't exist.

sorting unique arrays
+10 pts 10m
Lists & Arrays easy

Move Zeros to the End

Reorder a list in-place, pushing all zeros to the end while preserving the order of non-zero numbers.

lists in-place two-pointer
+10 pts 15m
Lists & Arrays easy

Chunk a list into n-sized parts

Write a function that divides a list into sublists of at most n elements.

list chunking slicing
+10 pts 15m
Lists & Arrays easy

Rotate Left by k

Implement a function that rotates a list left by k positions.

rotation lists slicing
+10 pts 15m
Lists & Arrays easy

Find Missing Number 1 to n

Given a list containing n-1 distinct integers from 1 to n, find the missing number without using extra space.

arrays math search
+10 pts 10m
Lists & Arrays easy

Interleave Two Lists

Write a function that interleaves two lists element by element, preserving order.

lists merge indexing
+10 pts 10m
Lists & Arrays easy

Keep only even indexes

Given a list, return a new list containing only the elements at even indices (0, 2, 4, ...).

list slicing indexing
+5 pts 5m
Lists & Arrays easy

Running Maximum

Implement a function that returns a list where each element is the largest value seen so far.

lists cumulative maximum
+10 pts 15m
Lists & Arrays easy

Difference of Consecutive Elements

Given a list of numbers, return a new list where each element is the difference between consecutive elements.

list iteration math
+8 pts 10m
Lists & Arrays easy

All Unique Values Keep Order

Remove duplicates from a list, keeping only the first occurrence of each value while preserving relative order.

deduplicate order list
+10 pts 15m
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

Average excluding min and max

Return the average of a list after discarding the lowest and highest elements, handling edge cases.

lists statistics sorting
+7 pts 10m
Lists & Arrays easy

Zip lists into pairs

Write a function that takes two lists and returns a list of two-element sublists pairing elements by index up to the shortest length.

zip lists pairs
+7 pts 10m
Lists & Arrays easy

Longest Run of Equal Values

Compute the length of the longest run (consecutive block) of equal elements in a list.

lists consecutive run-length
+8 pts 10m
Lists & Arrays easy

Middle Element of an Odd-Length List

Implement a function that returns the middle element of an odd-length list.

lists indexing basic
+5 pts 5m
Lists & Arrays easy

Is Subset of Another List

Write a function that returns True if every element in a given list exists in another list, ignoring duplicates.

subset membership lists
+8 pts 12m
Lists & Arrays easy

Unzip pairs into two lists

Write a function that takes a list of pairs and returns two separate lists: first elements and second elements.

zip unpacking lists
+10 pts 10m
Lists & Arrays easy

Generate a Multiplication Table

Build a function that returns an n x n multiplication table as a list of lists.

nested-loops list-comprehension matrix
+10 pts 10m
Lists & Arrays easy

Find Second Largest

Find the second largest unique number in a list, or None if it doesn't exist.

sorting max unique
+10 pts 10m
Lists & Arrays easy

Move Zeros to End

Rearrange a list by moving all zeros to the end while preserving the relative order of non-zero elements.

list in-place two-pointer
+10 pts 15m
Lists & Arrays easy

Majority Element Finder

Implement a function that returns the majority element in a list, which appears more than half the time.

majority frequency arrays
+10 pts 15m
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

Union of Two Lists

Implement a function that combines two lists and returns only unique elements.

union list set
+10 pts 15m
Lists & Arrays easy

Difference of Two Lists

Write a function that returns items in list a that are not in list b, preserving order and duplicates.

lists difference counting
+8 pts 10m
Lists & Arrays easy

Chunk list into groups

Implement a function that splits a list into sublists of a given size.

list slicing chunking
+10 pts 10m
Lists & Arrays easy

Zip Two Lists

Write a function that pairs elements from two lists by index, stopping at the shorter list.

zip lists pairs
+8 pts 10m
Lists & Arrays easy

Rearrange Positives and Negatives

Write a function that rearranges a list in-place so all negative numbers come before non-negative numbers.

in-place two-pointers partition
+10 pts 15m
Lists & Arrays easy

Wave sort array

Given a list of integers, reorder it into a wave pattern where elements alternate down-up, and return the new list.

sorting swap rearrangement
+10 pts 15m
Lists & Arrays easy

Last occurrence index

Implement a function that returns the last index of a given value in a list, or -1 if the value is not present.

lists indexing search
+10 pts 10m
Lists & Arrays easy

Counting Sort

Implement the counting sort algorithm to sort a list of non-negative integers in O(n + k) time.

sorting counting arrays
+10 pts 15m
Dicts & Sets easy

Word frequency

Return a dict mapping each word to its count in the sentence.

dict counter
+10 pts 10m
Dicts & Sets easy

List intersection

Return the sorted list of elements common to both lists.

sets intersection
+8 pts 8m
Dicts & Sets easy

First non-repeating character

Find the index of the first character that appears only once.

dict strings counter
1
+12 pts 12m
Dicts & Sets easy

Most frequent element

Return the element that appears most often in a list.

counter dict
+8 pts 8m
Dicts & Sets easy

Merge dicts summing values

Write a function that merges two dictionaries by summing values for duplicated keys.

dicts merge sum
+10 pts 10m
Dicts & Sets easy

Are two lists the same multiset

Write a function that checks if two lists contain the same elements with the same multiplicities, ignoring order.

multiset dictionary counting
+10 pts 10m
Dicts & Sets easy

Word to Index Map

Create a function that returns a dictionary mapping each unique word to the index of its first occurrence.

dictionary mapping indexing
+10 pts 10m
Dicts & Sets easy

Group names by first letter

Given a list of names, return a dictionary mapping each first letter to all names starting with that letter in original order.

dictionaries strings grouping
+10 pts 10m
Dicts & Sets easy

Missing keys default zero

Write a function to sum numeric values from dictionaries, treating missing keys as zero.

dictionaries sum defaults
+10 pts 12m
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

Nested get with dotted path

Implement a function that safely retrieves a value from a deeply nested dictionary using a dot-separated path, returning a default if any key is missing.

dicts nested parsing
+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

Mode of a list via counting

Implement a function that returns the mode of a list, resolving ties by the element that appears first.

counting dictionaries mode
+10 pts 15m
Dicts & Sets easy

Top k keys by count

Given a dictionary mapping keys to counts, return the top k keys with the highest counts, breaking ties alphabetically.

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

Values that appear once

Return a list of numbers that appear exactly once in the input list, in original order.

counting filtering order
+10 pts 15m
Dicts & Sets easy

Replace keys with a mapping

Write a function that renames keys in a dictionary according to a mapping, with duplicate handling.

dicts mapping transformation
+8 pts 10m
Dicts & Sets easy

Two Sum with Dict

Implement the classic Two Sum problem: return indices of two numbers that add up to a target using a dict.

dictionary pair-sum hash-map
+10 pts 15m
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

Sort by frequency

Sort a list by element frequency descending, with ties broken by order of first occurrence.

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

Pair with difference K

Count unordered index pairs with absolute difference exactly K, handling duplicates correctly.

dictionary set counting
+10 pts 15m
Dicts & Sets easy

Set intersection size

Count how many distinct values appear in both of two given lists.

sets intersection counting
+5 pts 8m
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
Dicts & Sets easy

Disjoint Set Check

Check if two lists are disjoint by verifying they have no common elements.

sets list membership
+10 pts 15m
Dicts & Sets easy

Subset of another set

Write a function that checks if every element of one set is contained in another.

sets subset membership
+10 pts 10m
Dicts & Sets easy

Frequency sort descending

Write a function that sorts a list by frequency descending while preserving original order for ties.

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

Count Pairs with Sum

Implement a function that counts the number of distinct pairs in a list summing to a target.

dictionary pair-counting hash-map
+10 pts 15m
Dicts & Sets easy

Ransom Note Builder

Given two strings, determine if the ransom note can be formed from the words in the magazine.

dictionary counting strings
+10 pts 15m
Functions & Closures easy

Bind First Argument

Implement bind_first_arg, a decorator that fixes the first argument of any function.

decorators closures functions
+10 pts 15m
OOP & Classes easy

Stack class

Implement a Stack class with push, pop, peek, is_empty, and size.

OOP stack data-structures
+12 pts 15m
OOP & Classes easy

Event emitter basics

Implement an EventEmitter class with subscribe/emit/unsubscribe functionality.

oop callbacks events
+10 pts 15m
OOP & Classes easy

Rectangle class

Implement a Rectangle class with properties, methods, and special methods for basic geometry and comparison.

classes magic-methods geometry
+10 pts 12m
OOP & Classes easy

Queue class (list-based)

Implement a Queue class with enqueue, dequeue, peek, is_empty, and is_full methods using a list.

queue oop list
+10 pts 15m
OOP & Classes easy

Abstract Base Class

Create an abstract Shape class and implement Rectangle and Circle subclasses with area and perimeter.

abc abstract oop
+10 pts 15m
Data Structures & Algorithms easy

Valid parentheses

Return True if brackets in the string close in the correct order.

stack strings
+15 pts 14m
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 easy

Index of peak element

Implement a function that returns the index of any peak element in a given integer array.

arrays search peak
+10 pts 15m
Data Structures & Algorithms easy

Count pairs with given difference

Count how many unordered pairs in a list have a given absolute difference using an efficient approach.

hash map counting arrays
+12 pts 15m
Data Structures & Algorithms easy

Previous Smaller Element

Find the nearest previous index with a smaller value for every element in an array.

arrays stack monotonic-stack
+10 pts 15m
Data Structures & Algorithms easy

Pascal Triangle Row

Given a non-negative integer n, return the nth row of Pascal's triangle as a list of integers.

math combinatorics arrays
+10 pts 15m
Data Structures & Algorithms easy

Employee Hierarchy

Build an employee hierarchy tree and compute the total number of direct and indirect reports for each employee.

tree dfs graph
+10 pts 15m
Data Structures & Algorithms easy

Union Find Class

Implement a UnionFind class with find and union operations supporting path compression and union by size.

union-find disjoint-set data-structures
+10 pts 15m
Data Structures & Algorithms easy

Bubble Sort

Implement bubble sort that sorts a list of numbers in ascending order.

sorting arrays algorithms
+8 pts 12m
Data Structures & Algorithms easy

Selection Sort Implementation

Implement selection sort to sort a list of numbers in ascending order.

sorting selection-sort algorithm
+10 pts 15m
Data Structures & Algorithms easy

Shell Sort

Implement Shell sort, an in-place comparison sort that generalizes insertion sort, using a gap sequence that shrinks by half each pass.

sorting shell-sort in-place
+10 pts 15m
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
Advanced Python easy

Infinite counter generator

Create an infinite counter starting from `start`, stepping by `step`.

generators itertools
+12 pts 12m
Advanced Python easy

Async Context Manager Lifecycle

Build an async context manager class that tracks acquisition and ensures cleanup.

async context-manager magic-methods
+10 pts 15m
Iterators & Generators easy

Custom iterator class

Implement a custom iterator class that repeatedly yields elements from a list up to a given number of times.

iterator class cycle
+10 pts 15m
Iterators & Generators easy

Generator Pipeline

Implement a generator function that yields only even numbers from an input list, squared.

generators lazy-evaluation filter
+8 pts 12m
Iterators & Generators easy

Range-like generator

Implement a custom generator that yields numbers like Python's range but with flexible bounds.

generator yield range
+8 pts 12m
Iterators & Generators easy

Fibonacci Generator

Create a generator function that yields Fibonacci numbers from 0 upward until a given limit.

generator fibonacci lazy evaluation
+8 pts 10m
Iterators & Generators easy

Window Iterator

Implement a generator that yields consecutive windows of a given size from any iterable.

generators yield sliding-window
+8 pts 12m
Iterators & Generators easy

Pairwise Sequence Pairs

Write a generator function pairwise that yields each consecutive overlapping pair from any iterable as lists.

generators iterators pairs
+10 pts 15m
Iterators & Generators easy

Groupby Consecutive

Write a generator function that yields (value, list_of_occurrences) for each run of consecutive equal items.

generator groupby consecutive
+8 pts 12m
Iterators & Generators easy

Collatz Generator

Implement a generator function that yields the Collatz sequence starting from a given positive integer.

generators collatz sequence
+10 pts 10m
Iterators & Generators easy

Digit Expansion Generator

Create a generator that lazily yields each decimal digit of a non-negative integer from most significant to least significant.

generators yield digits
+8 pts 10m
Iterators & Generators easy

File Line Reader Generator

Implement a generator function that reads a file-like object and yields each non-empty line without loading the whole file into memory.

generators file-io lazy-evaluation
+10 pts 15m
Iterators & Generators easy

Tree inorder generator

Write a generator function that yields a binary tree's node values in inorder traversal.

generator inorder binary-tree
+10 pts 15m
Iterators & Generators easy

Yield from delegation

Implement a generator that flattens nested iterables of any depth using `yield from`.

generators yield delegation
+8 pts 10m
Decorators & Context Managers easy

Once Decorator: Run a Function Only Once

Implement a decorator that caches and returns the result of the first call for subsequent calls.

decorators closures caching
+8 pts 10m
Decorators & Context Managers easy

Timing Decorator

Implement a decorator that prints the execution time of a function.

decorators time performance
+10 pts 15m
Decorators & Context Managers easy

Context Manager Class

Implement a context manager class that measures execution time and sets duration, with None if an exception occurred.

context-manager classes timing
+8 pts 12m
Decorators & Context Managers easy

Print Args Decorator

Write a decorator that prints function name and arguments, then returns the original result.

decorators functions wrappers
+10 pts 10m
Decorators & Context Managers easy

File Open Context Manager

Create a class that acts as a context manager for opening a virtual file in memory.

context-manager file-io python
+10 pts 15m
Decorators & Context Managers easy

Timer Context Manager

Implement a context manager that measures execution time of a with block and stores it.

context-manager timing measurement
+10 pts 15m
Decorators & Context Managers easy

Suppress stderr manager

Implement a context manager that suppresses all output written to stderr during its block.

context-managers stderr redirect
+8 pts 10m
Decorators & Context Managers easy

Context Decorator Dual

Implement a timing decorator and a context manager that both record elapsed time in seconds.

decorator context-manager time
+10 pts 15m
Error Handling & Exceptions easy

Safe Integer from String

Implement safe_int that converts a string to an integer, returning a default value on any failure, with support for an optional base.

exceptions parsing default-value
+10 pts 15m
Error Handling & Exceptions easy

Safe divide function

Implement safe_divide that returns None on ZeroDivisionError and TypeError.

try-except division error-handling
+8 pts 10m
Error Handling & Exceptions easy

Safe int parser

Implement safe_parse_int that converts a string to an int, returning a default value on failure.

exceptions parsing validation
+10 pts 10m
Error Handling & Exceptions easy

Safe Float Parser

Write a function that safely converts a string to a float, returning None for invalid inputs.

float exception parsing
+10 pts 10m
Error Handling & Exceptions easy

Divide with zero check

Write a function that safely divides two numbers, catching division by zero.

exceptions division error-handling
+8 pts 10m
Error Handling & Exceptions easy

Key error handler

Implement a safe dictionary access function that returns a default value on missing keys.

exceptions dict fallback
+8 pts 10m
Error Handling & Exceptions easy

Else on try block

Implement a function that uses try-except-else to safely divide two numbers and return a result or error description.

exception-handling try-except-else division
+8 pts 10m
Regular Expressions easy

Validate phone number

Write a function that uses regular expressions to determine if a given string is a valid US phone number.

regex validation phone
+10 pts 15m
Regular Expressions easy

Match IPv4 Address

Write a function that uses a regular expression to check if a string is a valid IPv4 address.

regex validation ipv4
+8 pts 12m
Regular Expressions easy

Validate Hex Color Code

Write a function that validates hex color codes using regular expressions.

regex validation strings
+10 pts 10m
Regular Expressions easy

Multiline anchor match

Extract lines beginning with a plain-text prefix from multiline strings using Python's re module.

regex anchors multiline
+10 pts 15m
Regular Expressions easy

Lookahead Validation

Write a regex-based function to check if a password meets length and character class requirements.

regex lookahead validation
+8 pts 10m
Math & Number Theory easy

Nth Triangular Number

Implement a function that returns the nth triangular number efficiently.

math formula integers
1
+10 pts 10m
Math & Number Theory easy

Clamp and round to nearest ten

Clamp a number between given bounds and round the result to the nearest ten with halves away from zero.

clamping rounding math
+10 pts 12m
Math & Number Theory easy

Integer Square Root Floor

Implement a function that returns the greatest integer whose square is ≤ n, using only integer operations.

math binary-search integer
+8 pts 12m
Math & Number Theory easy

Power set size

Compute the size of the power set of a given sequence.

math subsets counting
+8 pts 10m
Math & Number Theory easy

Polynomial evaluator

Implement a polynomial evaluator that computes the value of a polynomial given as a list of coefficients.

polynomial math evaluation
+5 pts 10m
Math & Number Theory easy

Catalan number

Implement a function that returns the nth Catalan number using dynamic programming.

math dynamic-programming combinatorics
+10 pts 15m
Math & Number Theory easy

Stirling number

Implement a function to compute Stirling numbers of the second kind S(n,k).

stirling-numbers dynamic-programming combinatorics
+10 pts 15m
Math & Number Theory easy

Euler Totient Function

Implement Euler's totient function φ(n) for positive integers.

math number-theory totient
+10 pts 15m
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
Math & Number Theory easy

Count divisors

Compute the number of positive divisors of a given integer using its prime factorization.

divisors prime factorization math
+10 pts 15m
Math & Number Theory easy

Sum of divisors

Given an integer n, return the sum of all its positive divisors.

divisors math number-theory
+10 pts 15m
Math & Number Theory easy

Perfect Number Check

Write a function that returns True if a number is perfect, i.e., equal to the sum of its proper divisors.

math divisors number-theory
+10 pts 15m
Math & Number Theory easy

Abundant Number Check

Implement a function to check whether a given integer is abundant: sum of proper divisors exceeds the number.

math divisors number-theory
+10 pts 15m
Math & Number Theory easy

Amicable Numbers Check

Write a function that checks if two numbers are an amicable pair by comparing sums of proper divisors.

divisors arithmetic math
+10 pts 15m
Math & Number Theory easy

Armstrong Number Check

Implement a function that checks if a given integer is an Armstrong number.

arithmetic number-theory validation
+10 pts 10m
Math & Number Theory easy

Happy number check

Implement a function that returns True if a number is happy, False otherwise.

math loops set
+8 pts 12m
Math & Number Theory easy

Harshad Number Check

Write a function that checks if a number is a Harshad (or Niven) number.

math digits divisibility
+8 pts 10m
Math & Number Theory easy

Triangular Number

Implement a function that returns the nth triangular number using the closed-form formula.

triangular formula math
+10 pts 10m
Math & Number Theory easy

Pentagonal Number

Given a positive integer n, return the nth pentagonal number using the formula P(n) = n(3n - 1)/2.

math formula integer
+10 pts 10m
Math & Number Theory easy

Lucas Sequence

Implement a function to compute the n-th Lucas number using iteration or recursion with memoization.

math sequence dynamic programming
+10 pts 15m
Math & Number Theory easy

Partition function

Write a function that returns the number of ways to write a positive integer as a sum of positive integers (order irrelevant).

math recursion memoization
+12 pts 15m
Math & Number Theory easy

Multiply without multiply

Write a function that multiplies two integers using only addition, subtraction, and bit shifts — no * operator.

multiplication bit-manipulation arithmetic
+8 pts 12m
Bit Manipulation easy

Count Set Bits

Implement a function that returns the number of set bits (1s) in the binary representation of a non-negative integer.

bit-manipulation binary counting
+10 pts 15m
Bit Manipulation easy

Check Power of Two Bits

Implement is_power_of_two(n) that returns True if n is a power of two and False otherwise.

bitwise power-of-two integer
+8 pts 10m
Bit Manipulation easy

Single Number XOR

Given a non-empty list of integers where every element appears twice except one, return the single number using XOR.

xor bit-manipulation arrays
+10 pts 12m
Bit Manipulation easy

Missing Number XOR

Given a list of n distinct numbers from 0 to n with one missing, use XOR to find and return the missing number.

xor bitwise arrays
+10 pts 15m
Bit Manipulation easy

Gray Code Encode

Implement a function that converts a non-negative integer to its Gray code representation using bitwise XOR and shift.

bitwise gray-code encoding
+10 pts 15m
Bit Manipulation easy

Gray Code Decode

Implement gray_decode(n) that converts an n-bit Gray code integer back to its standard binary value using XOR accumulation.

gray-code bit-manipulation xor
+10 pts 15m
Bit Manipulation easy

Find Rightmost Set Bit

Implement a function that returns the 1-indexed position of the rightmost set bit of a positive integer, or 0 if none.

bitwise bit-manipulation integer
+8 pts 12m
Bit Manipulation easy

Isolate Rightmost Set Bit

Given an integer, return a number with only its rightmost set bit set.

bit-manipulation bitwise algorithms
+10 pts 10m
Bit Manipulation easy

Rotate Bits Left

Implement a function that rotates the bits of an integer to the left by a specified number of positions.

bit-manipulation integer rotation
+10 pts 15m
Bit Manipulation easy

Add without plus

Implement a function that adds two integers using only bitwise operations, no arithmetic plus or minus.

bitwise addition xor
+10 pts 15m
Bit Manipulation easy

Set kth Bit

Implement a function that sets the kth bit (0-indexed) of a non-negative integer to 1 and returns the result.

bit-manipulation bits integer
+10 pts 15m
Bit Manipulation easy

Clear kth Bit

Implement a function that clears the k-th bit of a non-negative integer (turns it to 0) using bitwise operations.

bit mask integer
+10 pts 10m
Bit Manipulation easy

Compress Bits Run

Write a function that compresses a binary string by representing consecutive identical bits as a count-bit pair.

bit-manipulation strings compression
+10 pts 15m
Bit Manipulation easy

Sparse Number Check

Check if a non-negative integer is sparse, meaning its binary representation contains no adjacent 1 bits.

bitwise binary conditionals
+10 pts 15m
Bit Manipulation easy

Brian Kernighan count

Implement a function that counts set bits using Brian Kernighan's efficient algorithm.

bit-manipulation integers counting
+10 pts 15m
Dynamic Programming easy

Climbing Stairs

Implement a function that returns the number of distinct ways to climb n stairs using steps of 1 or 2.

fibonacci dp counting
+10 pts 15m
Dynamic Programming easy

Min cost climbing stairs

Compute the minimum total cost to reach the top of a staircase, given you can climb 1 or 2 steps at a time.

dynamic programming memoization array
+10 pts 15m
Dynamic Programming easy

House Robber

Given a list of house values, return the maximum sum you can rob without robbing two adjacent houses.

dynamic-programming arrays optimization
+10 pts 15m
Dynamic Programming easy

Unique Paths in a Grid

Count the number of unique paths from the top-left corner to the bottom-right corner of a grid, moving only right and down.

dynamic-programming grid counting
+15 pts 20m
Dynamic Programming easy

Triangle Minimum Path

Compute the minimum path sum from top to bottom of a triangle given as a list of lists.

dynamic-programming bottom-up arrays
+12 pts 20m
Trees & Binary Trees easy

Binary Search Tree Class

Build a BinarySearchTree class and a sequence runner that executes a list of operations.

binary-search-tree classes traversal
+10 pts 15m
Trees & Binary Trees easy

Binary Tree Inorder Traversal

Implement an inorder traversal function that returns node values in left-root-right order.

binary-tree traversal recursion
+10 pts 15m
Trees & Binary Trees easy

Preorder Traversal

Implement a function that returns the preorder traversal values of a binary tree.

binary-tree traversal recursion
+10 pts 10m
Trees & Binary Trees easy

Postorder Traversal

Implement a function that returns the postorder traversal of a binary tree as a list of node values.

binary-tree traversal recursion
+10 pts 15m
Trees & Binary Trees easy

Maximum depth of tree

Implement max_depth(root) to return the maximum depth of a binary tree.

binary-tree recursion depth
+10 pts 15m
Trees & Binary Trees easy

Minimum Depth of Tree

Given a binary tree, compute the minimum depth from the root to the nearest leaf node.

binary-tree depth traversal
+10 pts 15m
Trees & Binary Trees easy

Symmetric Tree Check

Write a function that checks whether a binary tree is symmetric (a mirror of itself).

binary-tree recursion mirror
+10 pts 15m
Trees & Binary Trees easy

Same Tree Check

Write a function that checks whether two binary trees are identical in structure and node values.

binary tree recursion tree traversal
+10 pts 15m
Trees & Binary Trees easy

Insert into BST

Implement insertion into a Binary Search Tree while maintaining BST properties.

binary-search-tree recursion tree
+10 pts 15m
Graphs & Graph Algorithms easy

Cycle Detection in a Directed Graph

Use DFS with a recursion stack to detect cycles in a directed graph.

graph dfs cycle
+10 pts 15m
Graphs & Graph Algorithms easy

Cycle Detection in Undirected Graph

Write a function that detects if an undirected graph contains a cycle.

graph dfs cycle-detection
+10 pts 15m
Graphs & Graph Algorithms easy

Find the Town Judge

Given n people and a trust array, return the town judge or -1.

graph indegree outdegree
+10 pts 15m
Graphs & Graph Algorithms easy

Find center of star graph

Write a function that finds the center node of a star graph from its list of edges in O(1) time.

graph star-graph array
+10 pts 15m
Graphs & Graph Algorithms easy

Keys and Rooms

A classic graph traversal challenge: check if all rooms are reachable from room 0 using keys found in visited rooms.

graph dfs bfs
+10 pts 20m
Recursion & Backtracking easy

Wildcard Match (Simple)

Write a function that checks whether a string matches a pattern with '*' and '?' wildcards.

wildcard recursion string
+10 pts 15m
Recursion & Backtracking easy

Permutation Generator

Write a function that returns all permutations of a list of distinct integers.

recursion backtracking permutations
+10 pts 15m
Greedy Algorithms easy

Stock Buy Sell Once

Given daily stock prices, compute the maximum profit you can achieve from buying once and selling once later.

array profit max
+10 pts 15m
Two Pointers & Sliding Window easy

Best Time to Buy and Sell Stock

Given a list of daily stock prices, determine the maximum profit achievable by buying on one day and selling on a later day.

arrays sliding-window profit
+10 pts 15m
Two Pointers & Sliding Window easy

Longest Substring Without Repeating Characters

Implement a function that returns the length of the longest substring without repeating characters.

strings sliding-window two-pointers
+10 pts 15m
Stacks & Queues easy

Balanced brackets in string

Check if a string of brackets is properly balanced using a stack-based approach.

stack string parsing
+10 pts 15m
Stacks & Queues easy

Next Greater Element

Return a list where each position holds the next greater element to the right, or -1 if none exists.

stack arrays monotonic stack
+10 pts 15m
Heaps & Priority Queues easy

Min Heap Class

Build a MinHeap class with push, pop, peek, and size methods that maintain a valid min-heap.

heap priority-queue class
+10 pts 15m
Matrix & 2D Arrays easy

Valid Sudoku Board

Determine if a 9x9 Sudoku board is valid by checking rows, columns, and 3x3 sub-boxes.

matrix set validation
+10 pts 15m
Datetime & Time Calculations easy

Days in month

Write a function that returns the number of days in a given month and year, correctly handling leap years.

datetime calendar leap-year
+8 pts 10m

Showing 330 challenges · easy

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.