Curated sets

Interview core

The mediums that show up in real onsite loops.

All problems
Total results1,547 problems
TopicsJudge
High-Rise BuildingsGiven the heights of N buildings in a row, find the maximum number of other buildings visible in a straight line of sight from any single building.Medium5GeometryBrute force+2No attempts yet2s128 MBJudgeable
CocktailGiven a tree of N ingredients linked by N-1 known mass ratios, compute the smallest positive integer masses that satisfy every ratio.Medium5TreeDFS+2No attempts yet2s128 MBJudgeable
LampsGiven an N by M lamp grid where pressing a column switch exactly K times total flips columns, find the max number of rows that end up fully lit.Medium5Hash mapString+2No attempts yet2s128 MBJudgeable
DiceGiven a die net and N, stack N^3 dice into an N x N x N cube and minimize the sum of numbers on the five visible faces.Medium5ImplementationGreedy+2No attempts yet2s128 MBJudgeable
Lexicographically Largest SortGiven a distinct-integer array and a budget of at most S adjacent swaps, output the lexicographically largest array reachable within that swap budget.Medium5GreedyArray+1No attempts yet2s128 MBJudgeable
Unknown SentencePartition a sentence into segments that are anagrams of given words, minimizing total letters moved from their original word positions.Medium5Dynamic programmingString+1No attempts yet2s128 MBJudgeable
HotelGiven advertising costs and customer gains for up to 20 cities with unlimited repeats, find the minimum total cost to gain at least C new customers.Medium5Dynamic programmingMathNo attempts yet2s128 MBJudgeable
Maximum SumAssign digits 0-9 to letters A-J that encode N numbers so that the sum of the numbers is maximized while no number has a leading zero.Medium5GreedyMath+2No attempts yet2s128 MBJudgeable
PrefixGiven up to 50 words, find the largest subset where no word is a prefix of another, using a trie and tree DP.Medium5TrieDynamic programming+2No attempts yet2s128 MBJudgeable
Tree DiameterGiven a weighted tree with up to 100,000 vertices, compute the diameter as the maximum distance between any two vertices.Medium5TreeDFS+2No attempts yet2s256 MBJudgeable
ExerciseSimulate a pulse that rises by T when exercising and falls by R when resting (bounded between m and M) to find the minimum minutes needed to accumulate N exercise minutes, or report impossibility.Medium5GreedySimulation+1No attempts yet2s16 MBJudgeable
PartyGiven a directed weighted graph, compute for each village the round-trip shortest time to a fixed village X and return the maximum over all villages.Medium5Shortest pathGraph+1No attempts yet1s128 MBJudgeable
Farm ManagementCount 8-directionally connected groups of equal-height cells in a grid where every outside neighbor is strictly lower.Medium5BFSDFS+2No attempts yet2s128 MBJudgeable
Good NumbersGiven N integers, count how many of them equal the sum of two other numbers at two different positions in the sequence.Medium5Two pointersArray+1No attempts yet2s256 MBJudgeable
DictionaryConstruct the K-th lexicographically smallest string made of N 'a's and M 'z's using combinatorial counting, or report -1 if K exceeds the total count.Medium5CombinatoricsGreedy+1No attempts yet2s128 MBJudgeable
Wall-Breaking MazeFind the minimum number of walls to break on a grid path from the top-left to the bottom-right room, moving through 4 directions.Medium5BFSShortest path+1No attempts yet1s128 MBJudgeable
K-th NumberFind the k-th smallest value in the N x N multiplication table using binary search with a counting function.Medium5Binary searchMathNo attempts yet2s128 MBJudgeable
Run, HongjunGiven N billboard intensities and a sight range M, output the maximum intensity within a sliding window of size 2M-1 for each valid position.Medium5Sliding windowQueue+1No attempts yet2s256 MBJudgeable
X and KGiven X and K, find the K-th smallest positive integer Y such that X+Y equals X OR Y, which requires placing K's bits into the zero-bit positions of X.Medium5Bit manipulationMath+1No attempts yet2s128 MBJudgeable
Hopping FrogFind the minimum number of jumps for a frog moving between numbered stones, where each stone's value dictates allowed jump distances as multiples.Medium5BFSGraph+1No attempts yet2s128 MBJudgeable
Fixed-Length Reversal SortGiven a permutation of up to 8 numbers, find the minimum number of fixed-length K reversals needed to sort it, or report impossibility.Medium5BFSGraph+2No attempts yet2s128 MBJudgeable
Tangled Electric WiresGiven a matching between left and right poles, find the minimum number of wires to cut so no two remaining wires cross, which reduces to computing N minus the longest increasing subsequence.Medium5Dynamic programmingBinary search+1No attempts yet1s128 MBJudgeable
Watering FieldsGiven well-digging costs per field and pairwise pipe-connection costs, compute the minimum total cost to give every field water using an MST-style approach with a virtual water source.Medium5Minimum spanning treeGraph+1No attempts yet2s128 MBJudgeable
Paper FoldingDecide whether a strip of N labeled cells can be folded so the stack reads 1 to N from top to bottom, checking labels against the shrinking strip's two ends.Medium5Two pointersSimulation+1No attempts yet2s128 MBJudgeable
Woodcutter DasomChoose a single cut length for all logs to maximize total profit from selling equal-length pieces after subtracting per-cut costs.Medium5Brute forceSimulation+1No attempts yet2s128 MBJudgeable
Sunday Morning DateFind a grid path from S to F that first minimizes the number of trash cells stepped on, then minimizes clean cells adjacent to trash along that path.Medium5Shortest pathBFS+2No attempts yet2s128 MBJudgeable
DuelMatch N Team A fighters against N Team B fighters to maximize points, where a win scores 2, a tie scores 1, and a loss scores 0.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
Shortest Path Through Required VerticesGiven a weighted undirected graph, find the shortest path from vertex 1 to vertex N that must pass through two specified vertices.Medium5Shortest pathGraph+1No attempts yet1s256 MBJudgeable
String ExchangeGiven a circular string of a's and b's, find the minimum number of swaps to make all a's form one consecutive block.Medium5Sliding windowString+2No attempts yet2s128 MBJudgeable
Sejun and Sebi's WarGiven two armies whose weakest soldier dies each round (ties killing Sebi's soldier first), determine which side's soldier survives last.Medium5GreedySimulation+2No attempts yet2s128 MBJudgeable
Triangle SubsequenceGiven a sequence, find the longest subsequence where every triple of elements satisfies the triangle inequality.Medium5SortingTwo pointers+1No attempts yet2s128 MBJudgeable
World ConquestGiven population counts for N countries, find the maximum number of size-K groups where each group's members come from distinct countries.Medium5Binary searchGreedy+1No attempts yet2s128 MBJudgeable
Roads of the Northern CountryGiven the edges of a weighted tree of up to 10,000 cities, compute the length of the tree's diameter (the longest path between two nodes).Medium5TreeGraph+2No attempts yet1s128 MBJudgeable
Counting Crossing EdgesGiven M cross edges between two labeled vertex sets of size N, count how many unordered pairs of edges cross each other.Medium5SortingDivide and conquer+2No attempts yet2s128 MBJudgeable
New Year PartyPick a maximum-score guest list from a company tree so no employee and their direct manager both attend, computed with and without the root.Medium5Dynamic programmingTree+1No attempts yet2s128 MBJudgeable
Making the Best TeamChoose 15 players for white and 15 for black from a list of up to 1000 players to maximize the total ability sum.Medium5Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Sungji's Birthday PartyGiven N students each requiring a minimum number of other attendees to be satisfied, find the smallest group of students that can be invited so every invited student's requirement is met.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
Running MedianGiven integers one by one, output the running median (lower of the two middles when count is even) after each insertion.Medium5HeapSorting+1No attempts yet0.1s128 MBJudgeable
Captain DasomGiven N cannonballs, find the minimum number of tetrahedral-number piles whose sizes sum exactly to N using unbounded coin-change style DP.Medium5Dynamic programmingMath+1No attempts yet2s128 MBJudgeable
Number GameGiven a set of numbers including 1 and a limit K, find the first integer that cannot be formed using at most K chosen numbers, then decide the game winner by turn parity.Medium5Dynamic programmingMath+1No attempts yet2s128 MBJudgeable
Labels Without a Forbidden DigitGiven N and a forbidden digit L, find the N-th smallest positive integer whose decimal digits never contain L.Medium5MathCombinatorics+2No attempts yet2s128 MBJudgeable
Making a PalindromeFind the minimum number of integers to insert into a sequence so it becomes a palindrome, using interval or LCS-based dynamic programming.Medium5Dynamic programmingArray+1No attempts yet2s128 MBJudgeable
Power Strip SchedulingSimulate plugging devices into a strip with N outlets and, when full, evict the device whose next use is farthest away (or never used again), counting total unplugs.Medium5GreedySimulation+1No attempts yet2s128 MBJudgeable
Candidate RecommendationSimulate N photo frames where each recommendation either updates a displayed student's count or evicts the least-recommended, longest-displayed student to show the new one.Medium5SimulationHash map+2No attempts yet2s128 MBJudgeable
Number GroupingGiven N integers, decide which pairs to multiply instead of add so that the resulting total sum is maximized.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
TilingCount the number of ways to tile a 2×n rectangle using 2×1 and 2×2 tiles for multiple values of n up to 250.Medium5Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Maal GatheringGiven a grid with K-Maal pieces that jump up to K knight moves per turn, find the minimum total moves to gather all pieces on one square.Medium5BFSShortest path+2No attempts yet2s128 MBJudgeable
Balanced LineupGiven fans sorted by x-coordinate with a gender bit each, find the longest contiguous segment that has an equal number of men and women.Medium5Prefix sumHash map+2No attempts yet2s256 MBJudgeable
Sorting the BookshelfFind the minimum number of single-book relocations needed to sort a permutation of N books into increasing order.Medium5Dynamic programmingArray+1No attempts yet2s128 MBJudgeable
Word ExtensionGiven a dictionary and a starting 3-letter word, find the longest word reachable by repeatedly inserting one letter such that each intermediate word exists in the dictionary.Medium5Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Lexicographically Smallest Valid SequenceGiven a permutation S, construct the lexicographically smallest permutation T where each element differs from the corresponding S element by at most 1.Medium5GreedyArrayNo attempts yet1s128 MBJudgeable
Stacking BoxesSimulate stacking N axis-aligned boxes at given footprints using a 2D max-height map and report the final maximum height.Medium5SimulationArray+1No attempts yet3s128 MBJudgeable
Coin DistributionGiven several coin denominations with counts, decide for three test cases whether the coins can be split into two subsets of equal total value.Medium5Dynamic programmingArrayNo attempts yet2s128 MBJudgeable
Chemistry ExperimentDecide whether M mg of solution can be split into positive integer amounts per reagent so every reagent's linear gas formula a_i*x+b_i gives the same value, and output that value or 0.Medium5Binary searchMath+1No attempts yet2s128 MBJudgeable
Prime PathFind the minimum number of single-digit changes to transform one four-digit prime into another, keeping every intermediate number a four-digit prime, using BFS on the graph of primes.Medium5BFSGraph+1No attempts yet2s256 MBJudgeable
CheersGiven N people around a circle each drinking a cola brand, find the maximum number of non-crossing pairs connecting people with the same brand.Medium5Dynamic programmingIntervalsNo attempts yet2s128 MBJudgeable
Safe Squares on a ChessboardGiven a chessboard with queens, knights, and pawns, count squares that no queen or knight attacks, treating all pieces as movement blockers.Medium5SimulationImplementation+1No attempts yet2s128 MBJudgeable
Products of PrimesFind the N-th smallest number that can be formed as a product of one or more (with repetition) of K given distinct primes, using a heap-based merge.Medium5HeapMath+1No attempts yet2s128 MBJudgeable
Minimum Transfer RouteGiven several subway lines as sequences of stations, compute the minimum number of transfers to travel between two given stations using BFS over lines.Medium5BFSGraph+1No attempts yet1s256 MBJudgeable
SemitoneGiven a sequence of semitone moves, determine which of the 7 white-key starting notes keep every intermediate step on a white key and report each valid start/end note pair.Medium5SimulationImplementation+1No attempts yet2s128 MBJudgeable
OmokSimulate placing stones in given order on a 19x19 Gomoku board and find the first move that creates exactly 5 in a row (not 6+) for its color.Medium5SimulationImplementation+1No attempts yet2s128 MBJudgeable
Bug on a TreeGiven a tree with fruit values on vertices, find the maximum sum path (simple path) and its smallest-numbered starting endpoint.Medium5TreeDynamic programming+1No attempts yet2s128 MBJudgeable
AntsSimulate ants that reverse on collision by treating collisions as pass-throughs, then track identities to find which numbered ant falls off last and when.Medium5SimulationMath+1No attempts yet2s128 MBJudgeable
Bulbs and SwitchesGiven current and target bulb states, determine the minimum number of switch presses (each flipping a small neighborhood) needed, or -1 if impossible.Medium5GreedySimulation+1No attempts yet2s128 MBJudgeable
Building a BridgeGiven a grid of land and sea, find the shortest straight sea-cell bridge connecting two different islands.Medium5BFSArray+1No attempts yet2s192 MBJudgeable
Wine TastingPick numbers from a sequence maximizing sum while never selecting three consecutive elements.Medium5Dynamic programmingNo attempts yet2s128 MBJudgeable
In-Flight Meal TripFind the maximum-score path from city 1 to city N using at most M cities, moving only to strictly increasing city numbers along available flights.Medium5Dynamic programmingGraphNo attempts yet2s128 MBJudgeable
Similar WordsGiven up to 20,000 distinct words, find the pair with the longest common prefix, breaking ties by input order.Medium5StringSorting+1No attempts yet2s128 MBJudgeable
Field Mouse EscapeGiven mouse and tunnel coordinates plus a max travel distance, compute the minimum number of mice that cannot be matched to a distinct tunnel using bipartite matching.Medium5GraphGreedy+1No attempts yet2s128 MBJudgeable
Move by Breaking One WallFind the shortest path in a grid from top-left to bottom-right where you may break at most one wall along the way.Medium5BFSGraph+1No attempts yet2s192 MBJudgeable
Checking CausalityGiven send/receive events across computers with local clocks, detect whether the induced ordering constraints form a cycle indicating a causality violation.Medium5GraphTopological sort+1No attempts yet1s128 MBJudgeable
Team FormationPartition an age-ordered score sequence into contiguous groups to maximize the sum of each group's max-minus-min score.Medium5Dynamic programmingArray+1No attempts yet2s128 MBJudgeable
Plum TreeGiven a sequence of falling trees over T seconds, find the max plums caught starting at tree 1 with at most W moves between trees.Medium5Dynamic programmingNo attempts yet2s128 MBJudgeable
Tree Height and WidthGiven a binary tree's parent-child structure, place nodes on a grid by binary tree layout rules and find the level with the maximum column width, breaking ties by smallest level.Medium5TreeBFS+1No attempts yet2s128 MBJudgeable
Recover Tree PreorderGiven a tree's inorder and postorder sequences, reconstruct the tree and output its preorder traversal.Medium5TreeRecursion+1No attempts yet5s128 MBJudgeable
SequenceFind the K-th lexicographically smallest non-decreasing sequence of N positive integers summing to M.Medium5BacktrackingCombinatorics+1No attempts yet2s128 MBJudgeable
Theater SeatsCount permutations where each ticket holder sits in their own or adjacent seat, with VIP seats fixed and splitting the row into independent segments counted by a Fibonacci-like recurrence.Medium5Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
Buying JewelsFor each of n rows pick a contiguous non-empty subarray maximizing summed total value, breaking ties by fewest jewels then lexicographically smallest index sequence.Medium5Dynamic programmingArray+1No attempts yet2s128 MBJudgeable
Tree CuttingGiven a tree with n vertices, find the minimum number of edges to cut so some resulting piece has exactly m vertices, or report impossibility.Medium5TreeDynamic programming+1No attempts yet2s128 MBJudgeable
Pipe CuttingGiven M long pipes and N required short pipe lengths, compute the maximum number of short pipes that can be cut from the long pipes.Medium5GreedySortingNo attempts yet2s128 MBJudgeable
Height OrderGiven pairwise shorter-than relations between students, count how many students have their exact height rank fully determined by transitivity.Medium5GraphDFS+1No attempts yet1s128 MBJudgeable
Three SolutionsGiven up to 5000 distinct integers, find three distinct values whose sum is closest to zero, using sorting and two-pointer scanning.Medium5Two pointersSorting+1No attempts yet1s256 MBJudgeable
Brotherly Field DivisionChoose a non-decreasing staircase cut across N columns of an N x N grid to minimize the harvest difference between the two regions, and output one such cut.Medium5Dynamic programmingBrute force+1No attempts yet1s256 MBJudgeable
Inequality SignsGiven a sequence of < and > signs, place k+1 distinct digits 0-9 to satisfy all comparisons and output the lexicographically largest and smallest resulting digit strings.Medium5BacktrackingGreedy+1No attempts yet1s256 MBJudgeable
ParameciaSimulate a population where each individual matures, reproduces daily within an age window, dies at a fixed age, and count survivors on day N modulo 1000.Medium5Dynamic programmingSimulation+1No attempts yet1s128 MBJudgeable
Electric WiresGiven wires connecting positions on two poles, find the minimum removals so remaining wires never cross, equivalent to n minus the longest increasing subsequence.Medium5Dynamic programmingBinary search+1No attempts yet1s128 MBJudgeable
Colored Paper 3Given up to 100 aligned black 10x10 squares on a 100x100 grid, find the maximum area axis-aligned all-black rectangle.Medium5ArrayBrute force+1No attempts yet1s128 MBJudgeable
Folding a Tape MeasureSimulate folding a tape at marked positions for red, blue, then yellow dot pairs, tracking coordinate transformations and final folded length.Medium5SimulationMath+1No attempts yet1s128 MBJudgeable
Crossing the Stone BridgesCount ways to match a scroll string to positions across two parallel bridge strings, alternating bridges and strictly increasing positions.Medium5Dynamic programmingStringNo attempts yet1s128 MBJudgeable
Number BeadsSplit an ordered array into M contiguous groups to minimize the largest group sum, then output that value and the group sizes.Medium5Binary searchGreedy+1No attempts yet1s128 MBJudgeable
Finding the Middle MarbleGiven pairwise heavier-than relations among N odd marbles, count marbles that must be eliminated as the possible median using transitive closure of the order.Medium5GraphDFS+1No attempts yet1s128 MBJudgeable
Stable GroupGiven a like/dislike matrix, decide if people can be partitioned into groups (size at least 2) where members like each other within groups and dislike each other across groups, and output that partition.Medium5Union-findGraph+1No attempts yet1s128 MBJudgeable
Making a MazeFind the minimum number of black cells to convert to white so a path exists from top-left to bottom-right of an n x n grid, using 0-1 BFS or Dijkstra.Medium5BFSShortest path+1No attempts yet1s128 MBJudgeable
Glass BallsGiven B balls and M floors, compute the minimum number of drops needed to guarantee finding the critical breaking floor in the worst case.Medium5Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Running MediansGiven a sequence read one number at a time, output the running median every time an odd number of elements have been read.Medium5HeapImplementationNo attempts yet1s128 MBJudgeable
Cup HolderGiven a seat row with regular seats and adjacent couple-seat pairs that lack a middle cup holder, compute the maximum number of people who can access a cup holder, matching people to holders one per holder.Medium5GreedyString+1No attempts yet1s128 MBJudgeable
Dongjun's GameGiven N level scores, find the minimum total decrease needed to make the sequence strictly increasing while all scores stay positive.Medium5GreedyArray+1No attempts yet1s128 MBJudgeable
Observing Two StarsGiven start times and periods of two blinking stars, find the earliest simultaneous blink time and weekday, or report it never happens.Medium5Number theoryMath+1No attempts yet1s128 MBJudgeable
Trimming StringsFind how many top rows can be removed one at a time from a grid while all column strings (read top to bottom) remain pairwise distinct.Medium5Binary searchString+1No attempts yet1s256 MBJudgeable
Array Not Divisible by ThreeRearrange an array so no two adjacent elements sum to a multiple of 3, or report impossibility.Medium5GreedyMath+1No attempts yet1s128 MBJudgeable