Curated sets

Interview core

The mediums that show up in real onsite loops.

All problems
Total results1,547 problems
TopicsJudge
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
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
Stock MarketFind the contiguous subarray with the largest sum and report its 1-based start and end indices, breaking ties by smallest start then smallest end.Medium5Dynamic programmingGreedyNo attempts yet1s256 MBJudgeable
ImagineMaintain a 1024x1024 grid that starts as a checkerboard and process stickers plus rectangle queries for counts of each letter.Medium5Prefix sumArray+2No attempts yet1s256 MBJudgeable
Venus RoverChoose which stones to collect so total value is maximized, given limits on time and total lifted mass.Medium5Dynamic programmingNo attempts yet1s128 MBJudgeable
Olympic AvenuesGiven an undirected weighted graph with N up to 50, find the shortest path from S to F and, among ties, print the lexicographically smallest site sequence.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
The ClocksGiven nine clock dials and nine moves that each rotate a fixed subset of dials by 90 degrees, find the shortest move sequence that sets every dial back to 12 o'clock.Medium5Brute forceBacktracking+2No attempts yet1s256 MBJudgeable
IOIOICount the occurrences of the alternating string P_N (N+1 I's and N O's) as a substring of S, counting overlaps.Medium5StringSliding window+2No attempts yet1s256 MBJudgeable
FashionistaFor each day pick any clothing whose temperature range covers that day's high, maximizing the sum of absolute flashiness differences between consecutive days.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
JJOOIIFind the largest k such that k J's, then k O's, then k I's appear consecutively in the given string.Medium5StringPrefix sum+1No attempts yet1s128 MBJudgeable
Commute RouteCount monotone lattice paths from (1,1) to (w,h) that never turn at two consecutive intersections, modulo 100000.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Arranging Go StonesStones are added one by one; each even-indexed stone of a new color replaces the trailing run of the opposite color, and we count the white stones that remain.Medium5StackSimulation+2No attempts yet1s128 MBJudgeable
Longest Common SubstringGiven two uppercase strings of length up to 4000, find the length of the longest substring that occurs contiguously in both.Medium5Dynamic programmingString+2No attempts yet2s256 MBJudgeable
Quality InspectionGiven triples of parts (one of each type) with PASS or FAIL results, deduce for every part whether it is certainly good, certainly broken, or undetermined.Medium5ImplementationBrute force+1No attempts yet1s128 MBJudgeable
Listing Square Arrangements in Lexicographic OrderList every partition of n whose parts are non-increasing, and print the sequences in decreasing lexicographic order.Medium5BacktrackingRecursion+2No attempts yet1s128 MBJudgeable
Sum of a SequenceGiven an N by N table holding Ai+Aj for every pair of distinct indices and 0 on the diagonal, recover the original positive sequence A.Medium5MathArray+2No attempts yet1s256 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
Drunk CodingMaintain a sequence under point updates and answer range-product sign queries (+/-/0) for each test case until EOF.Medium5Segment treePrefix sum+2No attempts yet1s256 MBJudgeable
JolloGiven the Princess's three cards and two of the Prince's, find the smallest unused third card that lets the Prince win at least two rounds against any order of play.Medium5Brute forceGreedy+2No attempts yet1s128 MBJudgeable
Klingon Course LevelsPick a score threshold T that splits every division into basic and advanced groups, minimizing the sum over divisions of |basic - advanced|. Output that minimum.Medium5SortingPrefix sum+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
Odd or EvenPair each red number with a blue number to minimize how many pairs sum to an even value, since Mary wins those.Medium5GreedyMath+2No attempts yet3s128 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
Milk SchedulingGiven task durations and precedence constraints that form a DAG, find the minimum makespan when unlimited workers milk cows in parallel.Medium5GraphTopological sort+2No attempts yet1s128 MBJudgeable
Milk RoutingPick a single path from node 1 to node N minimizing latency plus X divided by the path's bottleneck capacity, and floor the result.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Clumsy CowsGiven an even-length string of parentheses, find the minimum number of characters to flip so the string becomes balanced.Medium5GreedyString+2No attempts yet1s128 MBJudgeable
TypoGiven a bracket string with at most one typo, count how many single-character flips turn it into a valid balanced bracket string.Medium5StringImplementation+2No attempts yet1s128 MBJudgeable
BookshelfPartition the books in order into shelves whose widths sum to at most L, minimizing the total of each shelf's maximum height.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
IslandsGiven heights along a line, find the maximum number of separate exposed segments at any single rising water level.Medium5SortingArray+2No attempts yet1s128 MBJudgeable
Cow IDsFind the N-th smallest binary number that has exactly K one-bits and no leading zeros, then print it in binary.Medium5CombinatoricsMath+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
Cow Beauty PageantGiven a grid with exactly two connected X regions, find the minimum number of dots to paint so the two regions become one.Medium5BFSGraphNo attempts yet1s128 MBJudgeable
Best ParenthesisGiven a balanced parenthesis string encoded as 0/1 values, compute its recursively defined score modulo 12345678910.Medium5StackRecursion+2No attempts yet1s256 MBJudgeable
Hexagonal Pasture NetworkGiven a hexagon-shaped grid of pastures, count and list all pastures at exact distance L from start H using BFS.Medium5GraphBFS+1No 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
The Big DanceRepeatedly split the interval 1..N at the middle (front group gets the extra when odd), pairing cows when a group has exactly two, and add each pair's product to a running sum.Medium5Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
Tea TimeStarting from a graph of known meetings, two cows meet whenever they share a mutual friend, and after all rounds settle, answer queries about whether each pair has met.Medium5GraphUnion-find+2No attempts yet1s128 MBJudgeable
Buying Feed, IIPick up to K pounds of feed from stores along a line, paying each store's price plus transport cost of distance carried, and minimize the total.Medium5GreedySorting+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
Relay RaceEach cow runs one lap, then signals other cows to start; find the time when the last cow finishes, ignoring repeat signals.Medium5GraphBFS+2No attempts yet1s128 MBJudgeable
Building a FenceCount the ordered ways to cut a plank of length N into four positive integer pieces whose longest piece is strictly shorter than the other three combined.Medium5CombinatoricsMath+2No attempts yet1s128 MBJudgeable
Pasture WalkingGiven a weighted tree with N vertices and Q queries, find the path length between each queried pair of vertices.Medium5TreeDFS+2No attempts yet1s128 MBJudgeable
Switching LightsMaintain a binary array of N lights under M range-toggle and range-count operations, and print each query result.Medium5Segment treeArray+1No attempts yet1s128 MBJudgeable
Hay For SaleGiven a wagon capacity and a list of hay bale volumes, find the largest total volume not exceeding the capacity that can be formed by choosing whole bales.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Best SpotGiven a weighted undirected graph and a set of favorite vertices, find the vertex whose average shortest-path distance to all favorites is smallest, breaking ties by smallest index.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
Sand CastleGiven current merlon heights and a multiset of target heights in any order, pair them to minimize the total cost of raising and lowering, where raising costs X and lowering costs Y.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
Cow Digit GameFor each starting number, players alternately subtract its largest or smallest nonzero digit, and the player who reaches 0 wins; decide if the first player wins.Medium5Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
Cow CashCount the number of unordered ways to make an amount N using V coin denominations, where each coin can be used any number of times.Medium5Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
Obstacle CourseOn an N by N grid with blocked tiles, find a walk from A to B that minimizes the number of 90-degree turns; start and end directions are free.Medium5BFSGraph+2No attempts yet1s128 MBJudgeable
Privileged CowsGiven a sequence of 1s, 2s, and 3s, find the minimum number of arbitrary swaps needed to group all 1s first, then all 2s, then all 3s.Medium5GreedyArray+2No attempts yet1s128 MBJudgeable
SunscreenEach cow accepts an SPF interval, each bottle has an SPF value and capacity; assign bottles to maximize the number of cows covered.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
String ConstructionRepeatedly take the leftmost or rightmost character of S and append it to T; among all such T, output the lexicographically smallest, wrapping lines at 80 characters.Medium5GreedyString+2No attempts yet1s128 MBJudgeable
Radar InstallationEach island on the sea side of a line must be covered by radars of reach d placed on the line, so find the minimum number of placements or report -1 if some island is unreachable.Medium5GreedyIntervals+2No attempts yet1s128 MBJudgeable
String Construction 2Build the lexicographically smallest string by repeatedly taking either the first or last character of the remaining string and appending it, with ties broken by comparing inward.Medium5GreedyTwo pointers+2No attempts yet1s128 MBJudgeable
Charm BraceletChoose a subset of N charms, each with a weight and a desirability, so that total weight stays within M and total desirability is maximized.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Cow ContestGiven the winners of head-to-head matches, count how many cows have a skill rank that is fully forced by the results.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Pearl PairingGiven counts of each pearl color, output the canonical pairing that matches the pearl at position i with the pearl at position i + N/2 in sorted order.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
The Loathesome Hay BalerRollers touch when center distance equals the sum of radii; find the path from the drive roller to the take-off roller and sum the absolute speeds, truncated.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Cow TravellingCount the number of walks of exactly T steps on a grid from a start cell to a target cell, where each step moves to a vertically or horizontally adjacent open cell.Medium5Dynamic programmingMatrix+2No attempts yet1s128 MBJudgeable
MunchingFind the length of a shortest grid path from the cow to the barn through grass, then report the number of grass squares munched along it.Medium5BFSGraph+2No attempts yet1s256 MBJudgeable
Cows on SkatesFind a shortest orthogonal path from (1,1) to (R,C) through open grid cells, breaking ties by the lexicographically smallest sequence of cells.Medium5BFSGraph+2No attempts yet1s128 MBJudgeable
Fence RepairSplit one board into N planks of given lengths; each cut costs the length of the piece being cut, so find the minimum total cost.Medium5GreedyHeap+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
Managing AllowanceFind the smallest fixed withdrawal amount K so that the N daily costs can be covered using exactly M withdrawals, counting forced top-ups and optional extra ones.Medium5Binary searchGreedy+2No attempts yet1s128 MBJudgeable
ATM PIN TheftGiven a sequence of observed key presses (digits and at most one backspace), count the four-digit PINs that could produce exactly that sequence of pressed keys.Medium5Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Chessboard DanceSimulate a beetle on an 8x8 board following move and turn commands, pushing chains of pieces that may fall off the board.Medium5SimulationImplementation+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
Prime LandGiven an integer x in prime-base form (prime powers in decreasing order), print the same representation for x - 1.Medium5Number theoryMath+2No attempts yet1s128 MBJudgeable
PacketsGiven counts of 1x1 through 6x6 square tiles, find the minimum number of 6x6 parcels needed to pack them all.Medium5GreedyImplementation+2No attempts yet1s128 MBJudgeable
Extended Lights OutGiven a 5 by 6 Lights Out board, find the unique set of button presses that turns every light off, then print the press grid.Medium5Brute forceBit manipulation+2No attempts yet1s128 MBJudgeable
EntropyFor each line of text, print the fixed 8-bit ASCII bit length, the optimal prefix-free Huffman bit length, and the compression ratio rounded to one decimal.Medium5GreedyHeap+2No attempts yet1s128 MBJudgeable
String ComputerCompute the minimum number of single-character insert, delete, or change operations needed to turn one string into another.Medium5Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Stockbroker GrapevineFor each directed weighted graph, find the vertex whose shortest paths reach every other vertex, minimizing the maximum distance; print it and that time, or disjoint.Medium5Shortest pathGraph+2No attempts yet1s128 MBJudgeable
FactFor each N up to 10000, find the last non-zero digit of N! and print it with N right-aligned in a field of width 5.Medium5MathNumber theory+2No attempts yet1s128 MBJudgeable
Extrapolation Using a Difference TableExtend a sequence by k steps using a polynomial difference table, always assuming the highest-order differences stay constant, and print the (n+k)-th term.Medium5MathDynamic programming+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
SlurpysGiven up to 10 short strings, decide whether each one is a Slurpy, meaning a Slimp followed by a Slump under the recursive grammar in the statement.Medium5RecursionString+2No attempts yet1s128 MBJudgeable
Power ShortageGiven a connected weighted undirected graph, keep a subset of roads so every pair of houses stays connected while maximizing the total length of removed roads.Medium5Minimum spanning treeGraph+2No attempts yet1s256 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
El DoradoCount the increasing subsequences of length exactly k in a sequence of n distinct numbers, for several test cases.Medium5Dynamic programmingArray+1No 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
Basic Wall MazeGiven a 6 by 6 grid, three blocking walls, a start and an end square, print the lexicographically smallest shortest path using N, E, S, W moves.Medium5BFSGraph+2No attempts yet1s128 MBJudgeable
Wine Trading in GergoviaGiven net wine demands along a line summing to zero, find the minimum total transport cost (one unit per bottle per adjacent step).Medium5GreedyPrefix sum+2No attempts yet1s128 MBJudgeable
106 Miles to ChicagoGiven a graph where each edge has a percent probability of staying uncaught, find the path from node 1 to node n that maximizes the product of these probabilities.Medium5GraphShortest path+2No attempts yet1s128 MBJudgeable
The Sierpinski FractalDraw the outline of a depth-n Sierpinski triangle in ASCII, 2^n rows tall, with no trailing spaces and blank lines between the test cases.Medium5Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
Code the TreeParse a parenthesized tree description, then repeatedly remove the smallest-numbered leaf and print its neighbor to build the Prufer code.Medium5TreeImplementation+2No attempts yet1s128 MBJudgeable
Decode the TreeGiven a Prüfer code, rebuild the labeled tree on n vertices and print it as a canonical rooted word with children sorted by number.Medium5TreeHeap+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
Quad TreeDecode a quad tree string into an n by n black and white image, then print each row as XBM hexadecimal bytes.Medium5RecursionDivide and conquer+2No attempts yet1s128 MBJudgeable
FriendsEvaluate set expressions over uppercase letters using union, intersection, and difference, where * binds tighter than + and - and equal operators left-associate.Medium5StringStack+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
France '98Given win probabilities for every pair of 16 teams and a fixed bracket, compute each team's probability of winning the single-elimination tournament.Medium5Dynamic programmingProbability+2No attempts yet1s128 MBJudgeable
Solving Linear EquationsParse each linear equation written in a recursive grammar with parentheses and multiplication, then report no, infinite, or the unique solution rounded to six decimals.Medium5MathRecursion+2No attempts yet1s128 MBJudgeable
Humble NumbersFor each n up to 5842, print the nth number whose only prime factors are 2, 3, 5, or 7, formatted with the correct English ordinal suffix.Medium5Dynamic programmingMath+2No attempts yet1s128 MBJudgeable
Rhinoceros BeetleGiven shared community cards and each player's two hole cards, evaluate every player's best five-card poker hand and print the indices of all winners.Medium5ImplementationSorting+2No attempts yet2s128 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
String EncryptionClean the plaintext (drop spaces, uppercase), then invert the given transposition decryption rule to produce the matching ciphertext.Medium5StringImplementation+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
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
Sea BattleCount rectangular ships of '#' cells on a grid, verify no two touch even diagonally, and report bad placement if the ships are not valid rectangles.Medium5ImplementationArray+2No attempts yet1s128 MBJudgeable