Problems

Pick a problem and write your solution in the built-in editor. The judge runs it against real test cases while you watch, and the wider archive is open to read whenever you like.

Total results52 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Recently Used DocumentsSimulate a most-recently-used list of capacity k: each opened document moves to the front, new ones are inserted there and the back is dropped when full, then print the final list.Easy2SimulationImplementation+2No attempts yet1s512 MBJudgeable
LRU CachingSimulate an LRU cache over a sequence of letter accesses and exclamation-mark print requests, outputting cache contents from least to most recently used.Easy3Linked listHash map+1No attempts yet1s128 MBJudgeable
Queue 2Implement a queue supporting push, pop, size, empty, front, and back, and run N commands, printing output for the query commands.Easy3QueueImplementation+2No attempts yet1s512 MBJudgeable
Popping BalloonsSimulate popping balloons arranged in a circle, moving left or right by the value on each popped balloon among remaining balloons.Medium4SimulationLinked list+1No attempts yet2s4 MBJudgeable
Nearest Common AncestorGiven a rooted tree and two nodes, find their nearest common ancestor for each test case.Medium4TreeDFS+1No attempts yet1s128 MBJudgeable
Army BuddiesAfter each loss report removes living soldiers L through R, print the nearest surviving neighbors on both sides, or * when none exists.Medium4Union-findLinked list+1No attempts yet1s128 MBJudgeable
Cow LineMaintain a deque of cows under left/right insertions and left/right bulk removals, then print the remaining cows left to right.Medium4QueueLinked list+2No attempts yet1s128 MBJudgeable
The RaceGiven the starting order of cars and a recorded list of adjacent overtakes, verify the sequence is valid and print the final order or the first impossible overtake.Medium4SimulationArray+2No attempts yet1s1024 MBJudgeable
Rearranging a SequenceGiven the sequence 1 to n, each request moves a named integer to the front while keeping the rest in order; output the final sequence.Medium4Linked listImplementation+1No attempts yet2s512 MBJudgeable
Overflowing BookshelfSimulate a fixed-width shelf through add (push books leftward) and remove events; at End list the surviving books left to right.Medium5SimulationImplementation+2No attempts yet1s128 MBJudgeable
KeyloggerA log of typed keys, arrow moves, and backspaces in a text field must be replayed to recover the final password.Medium5Linked listSimulation+1No attempts yet1s256 MBJudgeable
Cleaning the DishesSimulate two stacks where each wash or dry command reverses the order of the dishes it moves, then print the final cleaned pile top to bottom.Medium5SimulationStack+2No attempts yet1s128 MBJudgeable
Gondola sequence checkDecide whether n observed gondola numbers could appear as consecutive passings on a circle where broken gondolas are replaced in order by numbered spares.Medium5SimulationHash map+1No attempts yet1s256 MBJudgeable
Traffic (Small)Given a tree and Q tickets, count how many tickets use each edge along the unique path, then report the edge with the largest count (smallest station pair on ties).Medium5TreePrefix sum+2No attempts yet2s512 MBJudgeable
Snail ListA linked list has a tail node N pointing back to node V, forming one cycle. For each query K, report the value stored in the node reached after moving K steps from node 1.Medium5Linked listArray+2No attempts yet1s256 MBJudgeable
Doubly Linked ListGiven a sequence of doubly linked list move operations, output the minimum number of operations that reverse them and restore the original order.Medium6Linked listStack+1No attempts yet1s128 MBJudgeable
AlphabetSimulate inserting tokens into a growing circular list by repeatedly stepping k tokens forward and inserting the next alphabet letter, then report the letter inserted on turn m (up to 1e9), requiring an efficient data structure rather than brute simulation.Medium6Linked listSimulation+1No attempts yet2s64 MBJudgeable
Colorful VillageMaintain N houses under range repaint operations and answer queries counting how many of the T colors appear in a range.Medium6Segment treeBit manipulation+2No attempts yet2s512 MBJudgeable
Space ManagerSimulate a disk with insert, remove, and compact operations using best-fit placement, then print an eight-block free-space picture or a full-disk error.Medium6SimulationImplementation+2No attempts yet2s512 MBJudgeable
Student CanteenStudents numbered by arrival either join the back of a queue or cut in right ahead of an earlier student; report each cutter's 1-indexed position at that moment.Medium6ImplementationLinked list+1No attempts yet1s512 MBJudgeable
Linked ListMaintain a permutation of 1..N under slide(a,b) moves (move a to just after b), reporting how far a moves each time and printing the final list.Medium6Linked listArray+2No attempts yet1s512 MBJudgeable
Problem About Solving Problems (Dequery)Maintain a deque under queries that push the same value many times at either end, pop many elements, and read the k-th element; output each read.Medium6Linked listImplementation+2No attempts yet1s512 MBJudgeable
BackupGiven n sorted company positions on a line, choose k disjoint pairs (2k companies) minimizing the total sum of pairwise distances.Medium7GreedyHeap+2No attempts yet2s128 MBJudgeable
Cyclic MarathonRunners spaced around a circular track catch and eliminate the runner ahead, and the program prints the elimination order and the survivors.Medium7HeapLinked list+2No attempts yet3s256 MBJudgeable
Tree and Queries 2Answer path-cost and k-th-vertex queries on a weighted tree with up to 100,000 nodes and queries.Medium7TreeBinary search+2No attempts yet2s512 MBJudgeable
Man, Elephant, and RatMaintain a line of players cycling through three signs; range updates advance each player to the next sign, and range queries report counts of each sign.Medium7Segment treeLinked list+1No attempts yet2s512 MBJudgeable
Polyline SimplificationRepeatedly remove the interior point whose triangle area is smallest, breaking ties by original index, and report each removal index.Medium7HeapLinked list+2No attempts yet5s512 MBJudgeable
Zeroing FireGiven a center circle of radius R and two distinct shot points, find the area of all positions for a third shot whose circumcenter lies inside the center circle.Medium7GeometryMath+2No attempts yet1s512 MBJudgeable
Path EmbeddingGiven a tree and an ordering of its vertices, find the maximum tree distance between consecutive vertices in the ordering, capping the answer at 99.Medium7TreeLinked list+2No attempts yet1s512 MBJudgeable
New Game 2Simulate turns moving K stacked pieces on an N x N colored board, following white, red, and blue square rules, and report the turn when four pieces stack or -1.Medium7SimulationImplementation+2No attempts yet0.5s512 MBJudgeable
Card DroppingGiven the technique used for each dropped card in order, reconstruct the initial top-to-bottom ordering of cards 1..N that produces a sorted pile.Medium7SimulationLinked list+2No attempts yet2s1024 MBJudgeable
Colored BallsSimulate repeatedly deleting the longest run of same-colored balls (leftmost on ties), merging neighbors after each removal, and report when the k-th original ball is deleted.Hard8HeapLinked list+2No attempts yet2s128 MBJudgeable
Dividing ClassesGiven n students and m pairs who know each other's messenger ID, split them into the maximum number of classes so that any two students in different classes know each other, then output the class sizes.Hard8GraphBFS+2No attempts yet2s128 MBJudgeable
FirmProcess hires and queries on a growing rooted tree, counting employees at exact depth offset k below a given node at query time.Hard8TreeDFS+2No attempts yet2s512 MBJudgeable
Fibonacci MachineMaintain registers under range increment, answering range queries of the sum of Fibonacci values at the register entries, modulo 1e9+7.Hard8Segment treeMatrix+2No attempts yet2s512 MBJudgeable
Sequence and Queries 13Maintain an array under range add, range multiply, and range assign modulo 1e9+7, answering range sum queries.Hard8Segment treeLinked list+2No attempts yet2s512 MBJudgeable
Sequence and Queries 19Maintain an array under range add, range floor-division by d, and report the minimum and sum over a range. The division step needs a segment tree with min and sum.Hard8Segment treeLinked list+1No attempts yet2s512 MBJudgeable
Compass Card SalesRepeatedly remove the remaining card with the smallest uniqueness score, breaking ties by larger ID, and print the removal order.Hard8SimulationSorting+2No attempts yet6s512 MBJudgeable
Wookje and His FansMaintain a line of fans with club labels under deletions and range-count queries, where each query counts the maximal same-club run around an element.Hard8Linked listUnion-find+2No attempts yet2.5s256 MBJudgeable
Picking Numbers on a CirclePick exactly K numbers from a circle of N values so that no two chosen are adjacent, maximizing the sum.Hard8Dynamic programmingGreedy+2No attempts yet1s512 MBJudgeable
ANTSGiven a tree and a set of up to 50 marked nodes per query, find the node minimizing the sum of distances to all marked nodes, for up to 5000 queries.Hard8TreeDFS+2No attempts yet2s512 MBJudgeable
Metro LinesA tree is given, and for each query with two pairs of terminals, count the stations shared by the two paths between those pairs.Hard8TreeLinked list+2No attempts yet2s512 MBJudgeable
Rope and QueriesMaintain a string under up to 100,000 queries that cut a substring and move it to the front or back, and print single characters.Hard8Linked listImplementation+2No attempts yet0.3s512 MBJudgeable
Sequence and Queries 25Maintain an array under range bitwise AND, range bitwise OR, and range maximum queries, each value below 2^20.Hard8Segment treeBit manipulation+2No attempts yet2s512 MBJudgeable
Sequence and Queries 28Maintain an array under range add, range floor-sqrt, and range sum queries, and report each range sum.Hard8Segment treeMath+2No attempts yet1s512 MBJudgeable
Computer CacheMaintain a mutable byte array over m pieces, support range increments modulo 256 on a piece, cache loads of whole pieces into fixed cache positions, and point queries of cache bytes.Hard8Segment treeArray+2No attempts yet5s512 MBJudgeable
VisitsGiven a tree, a visiting order, fuel prices, and tank capacities, compute the refueling cost of each trip in the order.Hard8TreePrefix sum+2No attempts yet2s512 MBJudgeable
ADD, DIV, MAXMaintain an array under range add, range floor-divide, and range maximum queries, with N and Q up to 200000.Hard8Segment treeLinked list+2No attempts yet5s256 MBJudgeable
Falling BallsGiven slanted platforms whose endpoints move over time, find the final x-coordinate reached by a ball dropped at a given x.Hard9Segment treeTree+2No attempts yet2s1024 MBJudgeable
Lowest common ancestor in a dynamic forestMaintain a forest of rooted trees under link, cut, and lowest-common-ancestor queries, printing each LCA.Hard9TreeLinked list+2No attempts yet2s512 MBJudgeable
HackerSimulate substring comparisons, substring copy from a fixed string, and range letter-increment operations on a mutable string of length N.Hard9Segment treeHash map+2No attempts yet4s512 MBJudgeable
Sequence and Queries 39Maintain an array under range updates that add an arithmetic progression, and answer queries for the longest arithmetic-progression subarray inside a range.Hard9Segment treeMath+2No attempts yet2s512 MBJudgeable