25 live Coding / DSA scenarios
Coding & DSA Interview Questions
Easy Scenarios
2 challengesValidate Nested Bracket Sequences
Given a string containing round, square, and curly brackets, determine whether every bracket is properly opened and closed in the correct nested order.
Find a Pair Matching a Target
Given a sequence of integers and a target value, return the positions of two distinct entries whose values add to the target.
Medium Scenarios
20 challengesCheapest Route Within a Stop Limit
Given one-way routes between cities each with a cost, find the cheapest total cost from a source city to a destination city using at most k intermediate stops.
Minimum Coins to Reach an Amount
Given a set of coin denominations and a target amount, find the minimum number of coins (with unlimited supply of each denomination) needed to make exactly that amount, or report it is impossible.
Determine a Valid Course Completion Order
Given a number of courses and a list of prerequisite pairs, determine a valid order to complete all courses, or report that no valid order exists.
Maximum Sum Contiguous Subarray
Find the maximum sum of a contiguous subarray within a list of integers, with follow-up discussion of returning indices and handling a streaming variant.
Group Words by Letter Composition
Given a list of lowercase words, group together the words that share the exact same multiset of letters.
Count Connected Land Regions in a Grid
Given a 2D grid of land and water cells, count the number of distinct connected land regions, where cells are connected horizontally or vertically.
Longest Strictly Increasing Subsequence
Given a sequence of integers, find the length of the longest subsequence (not necessarily contiguous) whose elements are strictly increasing.
Longest Run of Non-Repeating Characters
Given a string, find the length of the longest contiguous substring in which no character repeats.
Merge Overlapping Room Bookings
Given a list of room booking intervals, each with a start and end time, merge all overlapping or touching intervals into the minimal set of consolidated bookings.
Find the Breaking Floor with Two Bulbs
Given two identical bulbs and a building with F floors, find the minimum critical floor at which a bulb breaks when dropped, while minimising the worst-case number of drops.
Track Connectivity Across a Growing Network
Given a number of servers and a sequence of direct connection events between pairs of servers, answer whether two given servers are connected after each event, processing many union and query operations efficiently.
Reverse a Segment of a Linked List
Given the head of a singly linked list and two positions m and n, reverse the nodes from position m to position n in place and return the new head.
Search in a Rotated Sorted Array
Given an array of distinct integers that was originally sorted ascending and then rotated at an unknown pivot, determine the index of a target value or report that it is absent.
Minimum Time for Contamination to Spread
Given a grid where each cell is empty, clean, or already contaminated, find the minimum time for all clean cells to become contaminated, spreading one step per unit time to adjacent cells, or report it is impossible.
Count Contiguous Runs Summing to a Target
Given a sequence of integers (possibly negative) and a target sum, count how many contiguous subarrays sum exactly to the target.
Partition a Set into Two Equal-Sum Groups
Given a set of distinct positive integers, determine whether it can be partitioned into two groups with equal sums, and if so, identify one valid grouping.
Maximize Sum with No Adjacent Elements
Given a list of integers, find the maximum sum you can obtain by choosing elements such that no two chosen elements are adjacent in the list.
Currency Conversion via Exchange Rate Graph
Given a list of direct exchange rates, find the effective conversion rate between any two currencies by multiplying rates along a path in a directed graph.
Validate the Binary Search Tree Property
Given the root of a binary tree, determine whether it satisfies the binary search tree ordering property across every subtree, not just immediate parent-child pairs.
Prefix Lookup Service for a Word Dictionary
Given a dictionary of words, build a structure that can efficiently answer whether any dictionary word starts with a given prefix, and how many words share that prefix.
Hard Scenarios
3 challengesTrack the Median of a Growing Stream
Design a structure that supports inserting numbers one at a time from a stream and efficiently reporting the median of all numbers seen so far.
Fewest Moves to Solve a Sliding Tile Puzzle
Given a small 2-by-3 sliding tile puzzle board with one blank space, find the minimum number of adjacent tile slides needed to reach a specified target arrangement, or report it is unreachable.
Maximum Value in Every Sliding Window
Given an array and a window size k, return the maximum value within every contiguous window of size k as it slides from left to right across the array.
