Index of peak element
Implement a function that returns the index of any peak element in a given integer array.
Count pairs with given difference
Count how many unordered pairs in a list have a given absolute difference using an efficient approach.
Find Peak Element
Implement a function that returns the index of any peak element in an integer array.
Previous Smaller Element
Find the nearest previous index with a smaller value for every element in an array.
Median of Two Sorted Arrays
Given two sorted arrays, return the median of the combined sorted array in O(log(min(n,m))) time.
Pascal Triangle Row
Given a non-negative integer n, return the nth row of Pascal's triangle as a list of integers.
Bubble Sort
Implement bubble sort that sorts a list of numbers in ascending order.
Find Peak Index
Given a list of integers, return the index of any peak element where the value is not smaller than its neighbors.
Count of Range Sum
Count contiguous subarrays whose sum lies in a given inclusive range using an efficient divide-and-conquer algorithm.
K Closest Elements
Implement a function to return the k closest elements to a target in a sorted array.
Next greater element II
For each element in a circular array, find the next greater element (NGE) to its right, wrapping around.
Merge time intervals
Given a list of time intervals, merge all overlapping intervals and return the merged intervals.
Consecutive available seats
Given a list of seat statuses, return the length of the longest consecutive run of available (0) seats.
Delete duplicates sorted II
Given a sorted list, remove duplicates in place so each element appears at most twice, returning the new length.
Arithmetic Slices Count
Given a list of integers, count how many contiguous subarrays of length at least 3 form an arithmetic sequence.
Showing 1–15 of 15 challenges · Data Structures & Algorithms
Data Structures & Algorithms — Python coding challenges
What you will find here
This page lists data structures & algorithms challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.
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.