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,786 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
The Genome Database of All Space LifeDecode a run-length compressed genome string with nested parentheses and print the character at index i, or 0 if the index is out of range.Medium6StringRecursion+2No attempts yet1s128 MBJudgeable
Adjacent EdgesRead several triangle meshes, label distinct vertices by first appearance, and for each triangle report the opposite vertex of the triangle sharing each of its three edges, or X when none exists.Medium6Hash mapGeometry+2No attempts yet1s128 MBJudgeable
Computer ScienceScore each page for a query word using occurrences in the page and in linking pages weighted by word distance to the hyperlink, then print the highest scoring pages.Medium6ImplementationString+2No attempts yet1s128 MBJudgeable
New FriendsGiven up to 10 town names, partition them into the fewest groups where every pair of names in a group differ by at most one Levenshtein edit (case ignored).Medium6StringGraph+2No attempts yet1s128 MBJudgeable
ToponymsGiven up to a million strings, find a subset maximizing the longest common prefix length times the subset size.Medium6StringTrie+2No attempts yet2s128 MBJudgeable
Valid Binary StringGiven a binary string with erased positions, decide whether the missing bits can be filled so the counts of 0 and 1 are equal and no character runs three times in a row.Medium6GreedyString+2No attempts yet1s128 MBJudgeable
Equal Is Not Really EqualGiven a string, decide whether a different string of the same length has an identical multiset of consecutive character pairs.Medium6GraphString+2No attempts yet1s128 MBJudgeable
PalindromeGiven a string, find the minimum number of characters to insert anywhere so the string becomes a palindrome.Medium6Dynamic programmingString+2No attempts yet1s256 MBJudgeable
The Third Smallest NumberGiven n distinct natural numbers, list all two-element ordered concatenations by value and report the third smallest.Medium6StringSorting+2No attempts yet1s128 MBJudgeable
Cellphone Keypad AutocompleteFor each word in a dictionary, compute how many letters a phone keypad must type when unique suffixes are autofilled, then print the average presses.Medium6TrieTree+2No attempts yet1s192 MBJudgeable
Balanced Cow BreedsCount the ways to 2-color the parentheses in a string so that each color class, read in order, forms a balanced parenthesis sequence.Medium6Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Secret MessageGiven M binary messages and N binary codewords, count for each codeword how many messages share a prefix relation with it in either direction.Medium6TrieString+2No attempts yet1s128 MBJudgeable
Cheapest PalindromeGiven a string and per-letter insertion and deletion costs, find the minimum cost to turn it into a palindrome by adding or removing characters anywhere.Medium6Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Computerizing a StockroomParse handwritten stockroom transactions in chronological order, track computers and part inventories, then print owner and stock summaries sorted by a custom phrase order.Medium6ImplementationString+2No attempts yet1s128 MBJudgeable
Round and Round We GoFor each given number, decide whether every product by 1 through its digit count is a rotation of its digits, keeping leading zeros.Medium6StringMath+2No attempts yet1s128 MBJudgeable
A Well-Formed ProblemParse a series of XML documents and decide whether each one satisfies six well-formedness rules, reporting the verdict per document.Medium6StringStack+2No attempts yet1s128 MBJudgeable
Code BreakingDecide whether some periodic permutation maps plaintext to ciphertext1, find the smallest valid period and permutation, then decrypt ciphertext2 with its inverse.Medium6ImplementationSimulation+2No attempts yet1s128 MBJudgeable
Car TriallingParse each line against a small case-sensitive grammar and decide whether it is a valid car-trialling instruction, echoing it with spaced collapsed or printing Trap!.Medium6StringImplementation+2No attempts yet1s128 MBJudgeable
Pascal Program LengthsCount the scored tokens (reserved words, identifiers, constants, parentheses, brackets, and listed operators) in each Turbo Pascal program, skipping comments and strings, and print the member's name with the total.Medium6StringImplementation+2No attempts yet1s128 MBJudgeable
PostScript Printer DriverSimulate a page renderer that places font C1 and 5x6 asterisk-font C5 strings on a 60x60 grid with left, right, center, and absolute justification, where blanks and dots never overwrite.Medium6SimulationImplementation+2No attempts yet1s128 MBJudgeable
The Finite State Text-Processing MachineSimulate several finite state machines over given input, matching transitions by input sets and printing each transition's output string until END is reached.Medium6SimulationGraph+2No attempts yet1s128 MBJudgeable
Dihedral GroupsNormalize a run-length abbreviated string of rotations r and reflections m into the unique shortest equivalent sequence under the dihedral group of order 2n.Medium6MathString+2No attempts yet1s128 MBJudgeable
Even a Kindergartner Could Solve ThisDecide whether each string over the alphabet {, }, and comma is a valid set by the given grammar, where brace characters can be either delimiters or atoms.Medium6StringDynamic programming+2No attempts yet2s128 MBJudgeable
Boolean LogicParse a fully parenthesized proposition formula, then print a truth table with each subformula's value placed at its symbol or operator column.Medium6ImplementationRecursion+2No attempts yet1s128 MBJudgeable
Run Length EncodingEncode each input line with run-length encoding: runs of 2 to 9 repeats become a count plus the character, longer runs split at 9, and everything else is wrapped in 1s with each 1 doubled.Medium6StringSimulation+2No attempts yet1s128 MBJudgeable
Bug CatcherFor each code line, repeatedly remove the first occurrence of a given bug string until no occurrence remains, then print the result.Medium6StackString+1No attempts yet1s128 MBJudgeable
Roman ExpressionsParse lines of Roman numeral arithmetic with ten registers, evaluating each assignment and printing the result or Error, handling RESET and QUIT.Medium6StringImplementation+2No attempts yet1s128 MBJudgeable
Comment removalStrip Pascal comments and collapse whitespace, honoring single-quote strings where doubled quotes are literals and comments can span lines.Medium6StringSimulation+2No attempts yet1s128 MBJudgeable
Sum of ProductsExpand a polynomial-like expression of variables into a sum of products, then sort each term's letters and sort the terms lexicographically.Medium6StringRecursion+2No attempts yet1s128 MBJudgeable
Snow ConesGiven the handed-out and requested flavors for a line of children, find the minimum number of simultaneous-neighbor-swap time steps until each child holds the requested flavor.Medium6GreedyTwo pointers+2No attempts yet1s128 MBJudgeable
Letter GameGiven up to 7 collected letters and a dictionary, find all words or pairs of words with the maximum total letter-value score, using each collected letter at most as often as it appears.Medium6StringHash map+2No attempts yet1s512 MBJudgeable
Recycling ProteinsGiven a source and target chain of amino acids, compute the minimum cost to convert one into the other using delete, insert, and replace with per-type costs.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
IP AddressesGiven a sequence of IP addresses added one by one, report which distinct addresses grep wrongly skipped because dots act as regex wildcards.Medium6StringHash map+2No attempts yet1s1024 MBJudgeable
Remove Redundant ParenthesesGiven valid arithmetic expressions over single uppercase variables with + and -, remove every matching parenthesis pair whose removal keeps the expression's value unchanged.Medium6StackString+2No attempts yet1s128 MBJudgeable
Gene FunctionAlign two DNA sequences by inserting blanks to maximize the sum of position-wise match values from a given table.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
Code FormattingParse a TRIVIAL program given by a grammar and print it back with strict indentation and whitespace rules.Medium6ImplementationRecursion+2No attempts yet2s128 MBJudgeable
String FoldingFind the length of the shortest folded sequence, using repeat counts like 3(AB), that unfolds to the given uppercase string.Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
Dory's PhonebookGiven a dictionary of words and a phone number, find every encoding of the number as a space-separated sequence of dictionary words, sorted lexicographically.Medium6TrieBacktracking+2No attempts yet1s128 MBJudgeable
VirusDecide whether every one of N integer sequences shares some contiguous fragment of length at least K, counting reversals as the same fragment.Medium6StringString matching+2No attempts yet1s128 MBJudgeable
Hidden CodeGiven plaintext/ciphertext pairs encrypted with a common repeating key, recover the shortest key or report that none works.Medium6StringMath+2No attempts yet2s512 MBJudgeable
SpamCount how many plain-text messages encode to the same spam encoding as a given message.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
Burger, French Fries, Soft DrinkCount the ways to cut a B/F/S stream into N consecutive blocks where every block has equal positive counts of each letter, or report Impossible.Medium6Dynamic programmingPrefix sum+2No attempts yet1s128 MBJudgeable
Chris MartinGiven a DNA string S of length n, find the smallest possible LCS length between S and any other length-n DNA string.Medium6Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Fibonacci WordsCount the occurrences of a given a/b pattern as a contiguous substring of the n-th Fibonacci word, overlaps included.Medium6StringDynamic programming+1No attempts yet1s128 MBJudgeable
The Concatenation of WordsCount the increasing selections of given words whose concatenation equals a pattern, capped at 1000000, and print the lexicographically smallest selection.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
SafeGiven a word and one rotation offset per wheel, find the minimum total turns to make all wheels display the same word.Medium6StringImplementation+2No attempts yet1s128 MBJudgeable
JanSplit a given lowercase word into the fewest pieces, each of which is lexicographically smaller than all of its nontrivial rotations, and print one valid minimum split.Medium6StringGreedy+2No attempts yet1s128 MBJudgeable
Bit SharkFind the length of the string left after repeatedly deleting the second half of any even-length palindrome, choosing deletions to maximize bits eaten.Medium6StringGreedy+1No attempts yet1s128 MBJudgeable
Diamond CipherThe program writes each password as signed powers of three and lists the Up and Down switches.Medium6MathString+1No attempts yet1s512 MBJudgeable
Paper FoldingRepeatedly fold the left part of a binary strip over the right where symbols match and find the shortest reachable length.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
LeetDecide whether the plain word can be split so each distinct letter maps to one fixed leet block of length at most k.Medium6BacktrackingString+1No attempts yet2s128 MBJudgeable
PeriodSplit string x into pieces to minimize the largest edit distance between y and any piece.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
Taunt BotSimulate a taunt bot that expands a fixed grammar with round-robin choices to print one taunt per three input words.Medium6SimulationString+1No attempts yet1s128 MBJudgeable
String Insert and PrintMaintain a single string under positional insertions and print the requested substring for each query.Medium6TreeString+1No attempts yet10s256 MBJudgeable
Largest Subsequence NumberPick digits from N in order, without a leading zero, to form the largest value that leaves remainder R when divided by Q.Medium6Dynamic programmingString+1No attempts yet3s128 MBJudgeable
Join the ConversationFind the longest chronological message chain where each message mentions the previous author, breaking ties by smallest indices.Medium6Dynamic programmingHash map+1No attempts yet2s128 MBJudgeable
Printing PlateFind the shortest plate that, pressed at every aligned position, leaves each fixed stripe in its own pure color.Medium6Binary searchSliding window+1No attempts yet1s256 MBJudgeable
Encryption SystemGiven an encrypted string, list every original string that the chained first-letter replacement turns into it.Medium6Brute forceSimulation+1No attempts yet1s256 MBJudgeable
Not a subsequenceGiven alphabet size k and string s, find the length of the shortest string over the alphabet that is not a subsequence of s and count such strings modulo 1e9+7.Medium6GreedyString+1No attempts yet2s256 MBJudgeable
Anagram PyramidsDecide whether dictionary words can link the base word to the apex word by deleting and rearranging one letter at each step.Medium6GraphBFS+1No attempts yet2s256 MBJudgeable
ZGODANGiven a non-handsome integer with up to 1000 digits, find the nearest integer whose consecutive digits alternate between even and odd, printing both on a tie.Medium6GreedyString+1No attempts yet1s32 MBJudgeable
Interval CompositionFind the maximum length L such that each of the two lowercase strings has a contiguous block of length L with the same letter counts.Medium6Prefix sumHash map+1No attempts yet1s256 MBJudgeable
Free WillyApply at most L of the given position permutations to turn the start word into the target word with the fewest steps.Medium6BFSGraph+1No attempts yet5s256 MBJudgeable
Zig Zag NametagGiven k, print the shortest lowercase string with adjacent letter differences summing to k, smallest alphabetically on ties.Medium6GreedyString+1No attempts yet1s256 MBJudgeable
MarkleftThe program converts each input line with nested markup rules for uppercase, quote escaping, decimal to hex, reversal, and verbatim copying.Medium6StackString+1No attempts yet1s256 MBJudgeable
DepactingDecode a nested Pact structure with run-length repeats and omitted record fields, then answer value queries on it.Medium6RecursionString+1No attempts yet1s256 MBJudgeable
InterpreterRun small integer programs with arithmetic, comparisons, if/else branches, while loops, and print statements.Medium6SimulationImplementation+2No attempts yet1s256 MBJudgeable
All Your Base (Small)Each test string is a numeral in an unknown base, with distinct symbols for distinct digits; find the smallest value it can represent, avoiding leading zeros.Medium6GreedyMath+2No attempts yet5s512 MBJudgeable
IgraGiven two length-N strings over {a,b,c}, permute the multiset from the second so no position matches the first and the result is lexicographically smallest.Medium6GreedyString+1No attempts yet1s64 MBJudgeable
PalinilapA lowercase string may be modified at exactly one position or left alone; find the maximum number of palindromic substrings achievable.Medium6StringDynamic programming+1No attempts yet1s512 MBJudgeable
Binary string restorationGiven counts of each of the four adjacent pairs, build the lexicographically smallest binary string of length a+b+c+d+1 that realizes them, or report impossible.Medium6StringGreedy+2No attempts yet2s256 MBJudgeable
Lexicographic SortingCount subsets of the integers in [A, B] whose lexicographic order as strings matches their numerical order, modulo 1e9+7.Medium6SortingString+1No attempts yet1s1024 MBJudgeable
Equivalent StringsDecide whether two equal-length strings are equivalent under recursive splitting and optional swap of halves.Medium6Divide and conquerString+2No attempts yet2s512 MBJudgeable
A and BGiven two strings of A and B, decide whether S can be turned into T using only: append A, or reverse then append B.Medium6GreedyString+2No attempts yet2s512 MBJudgeable
Robot MovementA robot walks on an infinite grid following a fixed-length string of U, D, L, R moves. Change at most M characters to maximize how many times it returns to the origin.Medium6Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Zeroes and OnesInvert two adjacent characters of either of two binary strings to make them equal, using the fewest operations, or report -1.Medium6MathString+2No attempts yet2s512 MBJudgeable
RATS SequenceSimulate a RATS sequence term by term for up to M steps, detecting the first term that repeats an earlier value or first takes the chain form 1233*4444 or 5566*7777.Medium6SimulationImplementation+2No attempts yet2s512 MBJudgeable
M and ADecide whether S can be interleaved character by character from a subsequence of S and a subsequence of T, both of the same length as S.Medium6Dynamic programmingStringNo attempts yet5s512 MBJudgeable
Shifting a MatrixParse a compressed shift-operation string with nested repetitions, apply the row and column rotations to an N by N matrix, and print the result.Medium6SimulationImplementation+2No attempts yet5s512 MBJudgeable
Prefix and SuffixCount the distinct substrings of S that both start with string A and end with string B, where A and B may overlap within a substring.Medium6StringHash map+1No attempts yet2s512 MBJudgeable
BracketsGiven a bracket string, decide whether flipping the brackets in at most one contiguous segment can turn the whole string into a balanced, valid bracket sequence.Medium6GreedyPrefix sum+2No attempts yet2s512 MBJudgeable
Bless You Autocorrect!For each target word, compute the fewest keystrokes using letter keys, tab (autocomplete to the most common dictionary word matching the typed prefix), and backspace.Medium6TrieDynamic programming+1No attempts yet3s512 MBJudgeable
Number of good substringsCount how many distinct substrings of s contain at most k bad letters, counting equal substrings once.Medium6StringHash map+1No attempts yet2s512 MBJudgeable
Musical PlagiarismGiven a song as a sequence of notes and a suspect excerpt, decide whether the excerpt appears in the song under some transposition (key change).Medium6String matchingArray+2No attempts yet2s512 MBJudgeable
Recover the Alphabet OrderGiven words claimed to be lexicographically sorted, decide whether the letter order is unique, impossible, or ambiguous.Medium6Topological sortGraph+1No attempts yet2s512 MBJudgeable
Around and Around We GoLay out two voices of a song as a round, aligning each voice's symbols so that simultaneous sounds share a column and gaps print as plus signs.Medium6SimulationImplementation+1No attempts yet2s512 MBJudgeable
Eleven LoverFor each number given as a digit string, count its substrings with no leading zero that are divisible by 11.Medium6MathPrefix sum+1No attempts yet8s512 MBJudgeable
Building Uppercase SentencesCount the distinct uppercase sentences you can form by deleting letters and grouping the rest into blocks of three identical letters.Medium6Dynamic programmingStringNo attempts yet1s256 MBJudgeable
Where To Go?A note string uses upper case letters and each station name uses lower case letters, so a match between them is an equality-pattern match between two windows of different alphabets.Medium6StringString matching+2No attempts yet2s512 MBJudgeable
Anadrome splitSplit a lowercase word into the fewest substrings that are each anagrams of some palindrome, breaking ties by the lexicographically smallest printed line.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Attendance Record 2Given a string of A, B, C, rearrange its letters into the lexicographically smallest valid schedule where B needs a rest day after working and C needs two.Medium6GreedyString+2No attempts yet2s512 MBJudgeable
Sherlock and Parentheses (Large)Given L opening and R closing parentheses, arrange a string of length L+R that maximizes the number of non-empty balanced substrings; output that maximum.Medium6StringGreedy+2No attempts yet5s512 MBJudgeable
Counting Distinct SubsequencesCount the distinct subsequences of a string, including the empty string, for up to 10,000 test cases.Medium6Dynamic programmingString+1No attempts yet1s512 MBJudgeable
Rather Perplexing Showdown (Small)Find the alphabetically smallest left-to-right lineup of R rocks, P papers, and S scissors so that a single-elimination bracket never pairs identical moves.Medium6Divide and conquerRecursion+2No attempts yet5s512 MBJudgeable
Fortune telling with sticksGiven an n by m letter grid and p query words, find for each word the longest contiguous substring that can be placed along a row or column in one of four directions.Medium6Brute forceImplementation+2No attempts yet2s512 MBJudgeable
Bovine Genomics (Gold)Given N spotted and N plain DNA strings of length M, find the shortest window of consecutive positions whose substrings separate every spotted string from every plain one.Medium6StringHash map+2No attempts yet2s512 MBJudgeable
Ant NestGiven paths of food names from the top floor down, print the merged tree with each node indented by two dashes per depth and children in dictionary order.Medium6TrieTree+2No attempts yet1s256 MBJudgeable
Flow Graph ComplexityParse a comma-separated flow-graph string of S, B(...), L(...) nodes, count forward and backward edges and nodes, and print |EF| + W*|EB| - |V| + 2 or -1 if malformed.Medium6StringImplementation+2No attempts yet1s512 MBJudgeable
Nothing But The TruthGiven facts about which person was at which place and when, count how many claims in a text (who met whom, who was where) are definitely false.Medium6StringIntervals+1No attempts yet2s512 MBJudgeable
Import SpaghettiFind a shortest cycle in a directed dependency graph and print it in lexicographically smallest rotation order, or report that none exists.Medium6GraphBFS+2No attempts yet2s512 MBJudgeable