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 results1,020 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
ZigZagGiven K words and N letters, output for each letter the word starting with it that has been used fewest times, breaking ties alphabetically.Medium4SortingHash map+2No attempts yet2s64 MBJudgeable
Programming ExamFor each query, decide whether two given substrings of S are anagrams, printing DA or NE.Medium4Prefix sumHash map+1No attempts yet3s128 MBJudgeable
AutomobileStarting from a matrix where each cell holds its row-major index, apply K row and column multiplications and report the total sum modulo 1e9+7.Medium4MathImplementation+2No attempts yet1s64 MBJudgeable
Go Go Go Special Action Force!Given a 9x9 grid of position codes, check whether each of the three groupings (columns, rows, and 3x3 blocks) contains all nine distinct codes.Medium4ImplementationMatrix+2No attempts yet3s512 MBJudgeable
N-Step SyllogismEach premise says all a are b; for each conclusion x is y, decide whether following the implication chain from x reaches y.Medium4GraphDFS+2No attempts yet2s128 MBJudgeable
SegmentationTrack visits per user over time and answer queries by mapping each user's recency and frequency to one of 12 RF segments.Medium4Hash mapImplementation+2No attempts yet1s1024 MBJudgeable
Trains crossing the Milky WaySimulate four seat operations across N trains, then count how many trains have a seating state that appears for the first time.Medium4SimulationHash map+2No attempts yet1s512 MBJudgeable
Drawing ArrowsEach point shoots an arrow to the nearest same-colored point; find the total length of all N arrows. Points are given unsorted, so sort them by position first.Medium4SortingHash map+2No attempts yet2s512 MBJudgeable
Drawing ArrowsEach point shoots an arrow to the nearest same-colored point; compute the total length of all arrows.Medium4SortingHash map+2No attempts yet1s256 MBJudgeable
ZamjenaGiven two arrays of numbers and variables, decide if one assignment of integers to variables makes corresponding positions equal. Consistent positions give constraints; any conflict answers NE.Medium4Hash mapImplementation+1No attempts yet1s64 MBJudgeable
KittyFind the longest contiguous substring with at most N distinct lowercase letters.Medium4Sliding windowTwo pointers+1No attempts yet1s512 MBJudgeable
String DiscriminationGiven a target string S and up to 100 words, decide whether S is a concatenation of words from the list, each reusable any number of times.Medium4Dynamic programmingString+1No attempts yet2s512 MBJudgeable
LazylandEach of n workers wants one of k jobs and costs b_i to reassign. Keep one worker per chosen job and reassign the cheapest extras to cover every missing job. Return the minimum total cost.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
Contest SettingCount the ways to choose k problems whose difficulties are all distinct, given n problems and their difficulty values, modulo 998,244,353.Medium4MathCombinatorics+2No attempts yet1s512 MBJudgeable
Back and ForthGiven ten bucket sizes at each of two barns, count the distinct amounts of milk that can end up in the first barn's tank after four alternating pours.Medium4Brute forceSimulation+2No attempts yet2s512 MBJudgeable
JarvisPick one integer X added to every factory frequency so that the count of indices with Ai + X = Bi is as large as possible.Medium4Hash mapArray+2No attempts yet1s512 MBJudgeable
Cipher DecoderCheck whether the multiset of integers in the ciphertext matches the multiset of character codes of the given plaintext.Medium4Hash mapSorting+2No attempts yet1s512 MBJudgeable
Pineapple AdvertisingAfter each of Q pizza deliveries to a house, report how many houses (the house itself plus its direct neighbors) like pineapple pizza for the first time.Medium4GraphHash map+2No attempts yet1s256 MBJudgeable
PatternGiven a sequence of grid points, decide whether it is a valid Android unlock pattern under the no-repeat and no-skipped-point rules.Medium4ImplementationSimulation+2No attempts yet1s512 MBJudgeable
StreetlightsGiven N integer points, decide whether for every pair (xi,yi), (xj,yj) the two reflected points (xi,yj) and (xj,yi) are also present.Medium4Hash mapSorting+2No attempts yet0.5s256 MBJudgeable
Jung's RestaurantDecide whether a customer's order satisfies the restaurant rules: special items need 20000+ in regular items, service items need 50000+ combined and at most one.Medium4Hash mapImplementation+2No attempts yet1s256 MBJudgeable
GPAGiven a catalog of courses with units, major requirements, and each student's grades, print each student's overall GPA and the GPA for every major whose requirements they completed.Medium4Hash mapString+2No attempts yet2s512 MBJudgeable
Baba is RabbitGiven commands of the form p is q, find all objects reachable from Baba by applying one or more commands, printed in lexicographic order.Medium4GraphDFS+2No attempts yet1s512 MBJudgeable
Flight TurbulenceA permutation maps each seat to the passenger sitting there; count how many passengers shift when one passenger demands their assigned seat.Medium4ArraySimulation+2No attempts yet1s512 MBJudgeable
Hardware SalesGiven three lists of (item ID, units) purchases, count items whose total units reach 20 or more in all three stores, printing IDs in first-appearance order.Medium4Hash mapImplementation+2No attempts yet1s512 MBJudgeable
Integer DivisionCount pairs of indices whose values give the same quotient when both are divided by d using floor division.Medium4Hash mapMath+1No attempts yet2s512 MBJudgeable
Problem ClassificationCount exact whole-word occurrences of each category's keywords in a statement, then print the categories with the highest total count in lexicographic order.Medium4Hash mapString+2No attempts yet1s512 MBJudgeable
Where Am I?Given a string of N mailbox colors, find the smallest K such that all length-K substrings are distinct. The answer is always at most N.Medium4StringBrute force+2No attempts yet1s512 MBJudgeable
AntsGiven N integers, some negative or very large, find the smallest nonnegative integer that does not appear among the valid nonnegative values.Medium4ArrayHash map+2No attempts yet2s512 MBJudgeable
Valid EmailsNormalize each email by its rules, count how many are valid and distinct.Medium4StringHash map+2No attempts yet2s512 MBJudgeable
LTBLRead match results between two teams, accumulate points, wins, draws, losses, and goals, then print the league table sorted by the six tiebreak rules.Medium4ImplementationSorting+2No attempts yet2s512 MBJudgeable
Multiverse IITwo universes are equal when their planet sizes give the same ordering and tie pattern; count pairs of the M universes that match.Medium4SortingHash map+1No attempts yet2s512 MBJudgeable
Coordinate CompressionFor each of N coordinates, output the number of distinct values smaller than it, which is its rank under coordinate compression.Medium4SortingHash map+2No attempts yet2s512 MBJudgeable
Sequence and Queries 38Maintain a sequence under append, delete-one-copy, and report running sum and XOR of all elements.Medium4Hash mapImplementation+2No attempts yet2s256 MBJudgeable
Cyber Opening CeremonyGiven start, end, and stream-end times plus chat logs, count members who chatted at or before the start and again between the end and stream-end.Medium4Hash mapImplementation+2No attempts yet1s1024 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
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
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
LaserGroup buildings by the ray from the origin, sort each group by distance, and find buildings whose laser is blocked by a closer, equally tall or taller building.Medium5GeometrySorting+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
Sum of Subarrays from Two ArraysCount pairs of contiguous subarrays, one from each of two arrays, whose sums add up to a given target T.Medium5ArrayHash map+1No attempts yet2s64 MBJudgeable
Number of RectanglesGiven up to 5000 points, count axis-aligned rectangles whose four corners are all present among the points.Medium5Hash mapCombinatorics+1No attempts yet2s128 MBJudgeable
Rotating SushiFind the maximum distinct sushi types among any k consecutive plates on a circular belt, adding one bonus for a given coupon type if not already present.Medium5Sliding windowHash map+1No attempts yet1s256 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
Counting Axis-Aligned Right TrianglesCount triangles among N points where the right angle vertex has one point sharing its x-coordinate and another sharing its y-coordinate.Medium5Hash mapMath+1No attempts yet1s128 MBJudgeable
Film FestivalGiven a bipartite graph of boat connections, count the number of pairs of left villages and pairs of right villages that form a complete K2,2 subgraph.Medium5CombinatoricsHash map+1No attempts yet1s128 MBJudgeable
T9Simulate a T9 keypad predictor that maps key-press sequences to dictionary words, splitting on key 1 as space and marking unmatched words with asterisks.Medium5StringHash map+1No attempts yet1s128 MBJudgeable
PINCount pairs of 4-character PINs (from a given list) that differ in exactly D of their four positions.Medium5Hash mapCombinatorics+1No attempts yet1s128 MBJudgeable
LinkerGiven modules with export/import tables and an entry symbol, find the reachable non-redundant modules, duplicate exports used by them, and unresolved imports.Medium5GraphBFS+1No attempts yet1s128 MBJudgeable
Hands of PokerGiven a five card poker hand, compute its unique rank value from 1 to 7462 that orders all possible hands consistently.Medium5SortingHash map+1No attempts yet1s128 MBJudgeable
DatabaseDetect whether any two rows in a table share equal values in two distinct columns, and if so output the lexicographically smallest violating row and column pair.Medium5Brute forceHash map+1No attempts yet1s128 MBJudgeable
Enchanted MirrorDecide if bricks with fixed (real,mirror) letter pairs can be permuted so the row reads T1 and its mirror reads T2, given initial words S1,S2.Medium5Hash mapString+2No attempts yet3s256 MBJudgeable
i18nGiven text lines, expand i18n-style abbreviations back into previously seen full words when the expansion is valid and unique, preserving capitalization and separators.Medium5StringHash map+1No attempts yet1s128 MBJudgeable
The Stable Marriage ProblemGiven male and female preference lists, compute and output the male-optimal stable matching using the Gale-Shapley algorithm.Medium5GreedySimulation+1No attempts yet1s128 MBJudgeable
Pathological PathsGiven a set of file paths defining a directory tree, resolve query paths (with '.', '..', and index.html shortcuts) and decide if two paths refer to the same existing file.Medium5StringHash map+2No attempts yet1s128 MBJudgeable
Soccer Bets16 shuffled match results with scores are given; reconstruct the single-elimination bracket and report the tournament winner.Medium5GraphImplementation+2No attempts yet1s128 MBJudgeable
Block GameGiven a 6x6 sliding block board and a special 1x2 piece, find the minimum number of slides to move it out through a gap on the right.Medium5BFSSimulation+1No attempts yet10s128 MBJudgeable
MeganominoesFor each query i, count unordered pairs of distinct tiles where one matching pair of ends touches and the two opposite ends sum to i.Medium5Hash mapBrute force+1No attempts yet1s128 MBJudgeable
Bridges and TunnelsAfter each new edge between two named buildings, print the size of the connected component that the edge joins.Medium5Union-findHash map+2No attempts yet3s128 MBJudgeable
BuzzwordsFor each line, strip spaces and report the highest occurrence count among substrings of length 1, 2, 3, and so on, stopping at the first length where no substring repeats.Medium5StringHash map+2No attempts yet1s128 MBJudgeable
Open SourceCount distinct students per project, drop any student who signed up for more than one project, then sort projects by count descending and name.Medium5Hash mapSorting+2No attempts yet1s128 MBJudgeable
A Multiple Made Only of OnesGiven n not divisible by 2 or 5, find the number of digits of the smallest repunit (all ones) that n divides.Medium5Number theoryMath+2No attempts yet1s128 MBJudgeable
Games R UsGroup users into equivalence classes by identical directory access sets, then report classes of size 2 or more.Medium5Hash mapSorting+2No attempts yet1s128 MBJudgeable
Index GenerationParse markers in a multi-page document, collect page references for primary and secondary index entries, and print the index sorted case-insensitively.Medium5StringSimulation+2No attempts yet1s128 MBJudgeable
Another Puzzling ProblemEach jigsaw piece carries four integer edge labels; match opposite labels to place every piece in the N by N grid, then print the assembled picture.Medium5ImplementationBrute force+2No attempts yet1s128 MBJudgeable
Abstract ExtractFor each article, pick the topic sentence of every paragraph with three or more sentences and print them in order.Medium5StringSimulation+1No attempts yet1s128 MBJudgeable
Auctions R UsSimulate one day of auctions: process auctions by end time, deduct each winning bid from the bidder's balance, and report winners or unmet reserves.Medium5SimulationSorting+1No attempts yet1s128 MBJudgeable
SquaresCount the number of squares whose four corners all come from a given set of integer-coordinate points, allowing tilted squares.Medium5GeometryHash map+1No attempts yet1s128 MBJudgeable
Sum of Squared DigitsFor two starting numbers, follow the sum-of-squared-digits map and report the smallest total length until a value appears in both sequences, or 0 if they never meet.Medium5Hash mapSimulation+2No attempts yet1s128 MBJudgeable
Organize Your Train part IICount distinct strings obtainable by splitting an input string at any point, optionally reversing each part, and concatenating the two parts in either order.Medium5StringBrute force+2No attempts yet1s128 MBJudgeable
Polygonal Line Shape SearchGiven a template orthogonal polygonal line, report which of up to 50 other lines match its shape under rotation and translation.Medium5GeometryImplementation+1No attempts yet1s128 MBJudgeable
Royal SuccessionGiven parent pairs for N people, compute each claimant's inherited fraction of the founder's blood and print the claimant with the largest fraction.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Manito ChainsGiven a permutation of N people, count the number of cycles in its functional graph. The input ends when N is 0.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
ClueGiven the cards you were dealt and the responses to your own Clue queries, determine which locations, weapons, and suspects could still be the hidden cards.Medium5SimulationImplementation+2No attempts yet1s128 MBJudgeable
And the Winner IsEach ballot has one character per candidate; discard any ballot that marks more than one candidate in the same race, then report the top vote-getter (ties included) in every race, in input order.Medium5ImplementationArray+2No attempts yet1s128 MBJudgeable
TransferGiven hypertubes each connecting K stations totally, find the fewest stations visited traveling from station 1 to station N.Medium5BFSGraph+2No attempts yet2s256 MBJudgeable
Life ConnectionsGiven an undirected friendship graph, count the distinct shortest paths between each queried pair of nodes, where path length counts nodes.Medium5GraphBFS+2No attempts yet1s128 MBJudgeable
Hauling OreFor each queried mine in an undirected graph, print all mines at shortest distance exactly 2, in alphabetical order.Medium5GraphBFS+2No attempts yet1s128 MBJudgeable
Jumbled LettersFor each query, find the longest dictionary word that can be formed using the query letters at most once, breaking ties alphabetically, or report IMPOSSIBLE.Medium5StringHash map+2No attempts yet1s128 MBJudgeable
Gene ShuffleTwo permutations of 1..N are given; split [1,N] into the shortest pieces where each piece holds the same set of genes in both. - use plain EnglishMedium5Prefix sumHash mapNo attempts yet1s128 MBJudgeable
Good NumbersCount the elements A_i that equal the sum of three elements appearing earlier in the sequence, where the same earlier element may be reused.Medium5Hash mapBrute force+2No attempts yet1s128 MBJudgeable
Pole PositionGiven the current race order of N cars with each car's position change from the start, reconstruct the starting grid or report that no valid grid exists.Medium5ArraySorting+2No attempts yet1s128 MBJudgeable
SupermarketGiven a shopping list and products in path order, buy the list items in order from later positions at minimum total cost, or report impossible.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Awkward DigitsGiven a binary string and a ternary string that each differ from the true base-2 and base-3 forms of N in exactly one digit, find N.Medium5Brute forceMath+2No attempts yet1s128 MBJudgeable
Bovine Bridge BattleCount sets of four points that are symmetric about some center, where each point pairs with its 180-degree rotation partner.Medium5Hash mapGeometry+2No attempts yet1s128 MBJudgeable
Word MorphGiven a dictionary of equal-length words, find the fewest one-letter changes needed to turn the start word into the end word through valid words.Medium5BFSGraph+2No attempts yet1s128 MBJudgeable
Patting HeadsEach of N cows has a value; for every cow count how many other cows hold a value that divides hers.Medium5MathNumber theory+2No attempts yet1s128 MBJudgeable
Bessie's Secret PastureCount the ordered quadruples (a,b,c,d) of non-negative integers whose squares sum to N, for N up to 10000.Medium5Hash mapMath+2No attempts yet1s128 MBJudgeable
Tallest CowGiven the tallest cow's height and index plus pairs where cow a sees cow b, find each cow's maximum possible height consistent with all observations.Medium5GreedyPrefix sum+2No attempts yet1s128 MBJudgeable
Crazy SearchCount how many distinct length-N substrings appear in a given text, where the text uses characters from an alphabet of size NC.Medium5StringHash map+2No attempts yet1s128 MBJudgeable
Erdös NumbersPapers list authors under titles, and each query asks the shortest co-authorship distance from Erdos; unreachable authors get infinity.Medium5GraphBFS+2No attempts yet1s128 MBJudgeable
Call ForwardingGiven timestamped call forwarding rules, follow each call through the active chain, printing the final extension or 9999 if a loop is entered.Medium5SimulationHash map+2No attempts yet1s128 MBJudgeable
Broken KeyboardFor each test case, find the length of the longest substring of the sentence that contains at most m distinct characters.Medium5Sliding windowString+2No attempts yet1s128 MBJudgeable
Automatic Typo CorrectionGiven a dictionary, classify each queried word as correct, a misspelling of the first similar dictionary word, or unknown, using three specific edit types.Medium5StringHash map+2No attempts yet1s128 MBJudgeable
Anagram GroupsGroup distinct words that are anagrams of each other, then print the five largest groups sorted by size and smallest word.Medium5Hash mapSorting+2No attempts yet1s128 MBJudgeable
Team QueueSimulate a team queue where each new element cuts in behind its own teammates, if any, and otherwise joins the tail; print every dequeued element.Medium5QueueHash map+2No attempts yet1s128 MBJudgeable
Collatz ConjectureFor each pair A and B, generate both Collatz sequences up to 1 and find the first value they share, reporting its index in each sequence.Medium5SimulationHash map+2No attempts yet1s128 MBJudgeable
God Save the i-th QueenGiven a board and placed queens, count empty squares not sharing a row, column, or diagonal with any queen.Medium5ArrayHash map+2No attempts yet1s128 MBJudgeable
Building a New DepotGiven the corner posts of an axis-aligned rectilinear polygon (listed in no particular order), reconstruct the polygon and compute its total perimeter.Medium5GeometrySorting+2No attempts yet1s128 MBJudgeable
StorehouseGiven a sequence of truck cargo requests and B bays, decide which bay holds which cargo type to minimize the number of loads, assuming optimal offline knowledge.Medium5GreedyHash map+1No attempts yet1s128 MBJudgeable