FizzBuzz, precisely
Return a newline-separated string for 1..n: Fizz, Buzz, FizzBuzz, or the number.
Temperature converter
Convert Celsius to Fahrenheit: F = C × 9/5 + 32.
Even or odd?
Return 'even' or 'odd' for an integer.
Sum of digits
Return the sum of all decimal digits of a non-negative integer.
Collatz steps
Count how many steps the Collatz sequence takes to reach 1 from n.
Factorial (iterative)
Compute n! iteratively without recursion.
Power of two?
Return True if n is an exact power of 2.
GCD via Euclid
Compute the greatest common divisor of two positive integers.
Fibonacci(n)
Return the nth Fibonacci number efficiently.
Prime checker
Return True if n is a prime number.
Reverse a string
Return the characters of the string in reverse order.
Palindrome check
Return True if the string reads the same forwards and backwards (ignoring case and non-alphanumeric).
Count vowels
Count the number of vowels (a, e, i, o, u) in a string (case-insensitive).
Title case converter
Return the string with each word capitalised.
Anagram check
Return True if two strings are anagrams of each other.
Run-length encoding
Compress consecutive identical characters, e.g. 'aaabbc' → 'a3b2c1'.
Longest common prefix
Find the longest common prefix among a list of strings.
Integer to Roman
Convert a positive integer to its Roman numeral representation.
Zigzag string conversion
Encode a string in zigzag order across numRows rows, then read row by row.
Two Sum
Return indices (i, j) with i < j such that nums[i] + nums[j] == target.
Maximum subarray (Kadane)
Find the contiguous subarray with the largest sum.
Rotate array
Rotate a list right by k positions in place.
Flatten nested list
Yield every integer from an arbitrarily nested list, depth-first.
Remove duplicates (sorted)
Return a sorted list with duplicates removed.
Merge two sorted arrays
Merge two sorted arrays into one sorted array.
Merge intervals
Merge all overlapping intervals and return a sorted result.
Product except self
Return an array where output[i] is the product of all elements except nums[i], without using division.
Sliding window maximum
Return the maximum of each window of size k as it slides across an array.
Word frequency
Return a dict mapping each word to its count in the sentence.
List intersection
Return the sorted list of elements common to both lists.
Group anagrams
Group words that are anagrams of each other.
First non-repeating character
Find the index of the first character that appears only once.
Most frequent element
Return the element that appears most often in a list.
Subarray sum equals K
Count the number of contiguous subarrays whose sum equals k.
Memoize decorator
Implement a @memoize decorator that caches results of a function.
Function composition
Return a function that applies f after g: compose(f, g)(x) == f(g(x)).
Curry a function
Auto-curry any multi-argument function so it returns partial applications until fully saturated.
Stack class
Implement a Stack class with push, pop, peek, is_empty, and size.
Linked list reversal
Implement a singly linked list and a function to reverse it in place.
Matrix addition operator
Implement a Matrix class that supports + and * operators.
Valid parentheses
Return True if brackets in the string close in the correct order.
Binary search
Return the index of target in a sorted list, or -1 if not present.
Quicksort
Implement quicksort and return a sorted list.
BFS level-order traversal
Return the level-order traversal of a binary tree as a list of lists.
Coin change (DP)
Find the minimum number of coins to make exactly the target amount.
LRU cache decorator
Implement @lru_cache(maxsize=N) for unary functions using OrderedDict.
Graph DFS
Return all nodes reachable from a start node via DFS.
Longest increasing subsequence
Return the length of the longest strictly increasing subsequence.
Topological sort (Kahn)
Return a valid topological ordering of tasks, or [] if a cycle exists.
Word ladder length
Return the length of the shortest transformation from beginWord to endWord changing one letter at a time.
Context manager timer
Implement a Timer context manager that records elapsed seconds.
Infinite counter generator
Create an infinite counter starting from `start`, stepping by `step`.
Retry decorator
Implement @retry(times=3) that retries a function on exception.
2D Vector dataclass
Implement a Vector2D dataclass with +, -, scalar *, dot product, and magnitude.
Data pipeline
Implement a Pipeline class supporting pipe chaining with the | operator.
Validated descriptor
Implement a TypedField descriptor that raises TypeError if the value is not of the expected type.
Showing 56 challenges