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 results139 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Huffman EncodingGiven prefix-free binary codes for up to 20 letters, decode a binary string of at most 250 digits back into the original letters.Easy3TrieString+2No attempts yet2s512 MBJudgeable
File Fix-it (Small)Count the mkdir commands needed to create each requested path from its missing prefixes.Easy3TrieStringNo attempts yet5s512 MBJudgeable
File Fix-it (Large)Count the directories along each wanted path that do not exist yet and report how many mkdir calls they need.Easy3TrieStringNo attempts yet5s512 MBJudgeable
Shortest PrefixesFor each word in a list, find the shortest prefix that matches only that word, counting an exact match as unique even if longer words share it.Medium4TrieString+2No attempts yet1s128 MBJudgeable
Phone ListGiven a list of distinct phone numbers, decide whether any number is a prefix of another.Medium4TrieString+1No attempts yet1s256 MBJudgeable
Disk TreeGiven full directory paths, rebuild the tree and print every directory name on its own line, indented by depth, with siblings in ASCII order.Medium4TrieSorting+1No attempts yet1s128 MBJudgeable
Auto-CompleteThe app prints the original index of the K-th dictionary word with each query prefix in alphabetical order, or -1.Medium4TrieSortingNo attempts yet1s128 MBJudgeable
Longest Prefix MatchGiven X bit prefixes with ids and Y destination addresses, print the id of the longest matching prefix for each address or -1.Medium4TrieBit manipulationNo attempts yet1s256 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
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
Word SearchGiven N database words compared in order against a query using character-by-character matching that also checks for word-end, compute total comparisons per query.Medium5TrieString+1No attempts yet1s128 MBJudgeable
Decoding Morse SequencesCount the number of ways to split a given Morse code string into a sequence of dictionary words, using dynamic programming with Morse-to-word conversion.Medium5Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Cow TypingGiven a dictionary and short email words, simulate the cow's letter selector with a trie and count total button presses, including circular highlight moves and prints.Medium5TrieString+2No attempts yet1s128 MBJudgeable
No Pause TelegraphGiven a string of dots and dashes and seven fixed letter codes, split it into codewords that minimize the resulting message alphabetically, or report that no split exists.Medium5Dynamic programmingString+2No attempts yet1s128 MBJudgeable
77377Split a digit string into dictionary words whose telephone-keypad encoding matches each segment.Medium5Dynamic programmingTrie+1No attempts yet1s128 MBJudgeable
Prefix-Free SubsetsCount the subsets of the given word set in which no word is a prefix of another word.Medium5TrieDynamic programming+1No attempts yet1s128 MBJudgeable
Find the Hidden WordGiven a list of known words and several messages, find which listed words occur as substrings in each message and report NO, the unique word, or AMBIGUOUS.Medium5String matchingTrieNo attempts yet1s256 MBJudgeable
BoggleFind every dictionary word that can be spelled on each letter grid with adjacent cells and no cell reused, treating q as qu.Medium5BacktrackingTrie+1No attempts yet1s256 MBJudgeable
Trie Sharding (Small)Split up to 8 strings across labeled servers to maximize the summed trie node counts and count the optimal splits.Medium5Brute forceTrie+1No attempts yet5s512 MBJudgeable
DNA SequencingEach printed line can be trimmed to any prefix; pick prefixes of length at least M so the number of distinct resulting strings is maximized.Medium5TrieString+2No attempts yet2s512 MBJudgeable
Finding PrefixesGiven a set of N strings, count how many of M query strings appear as a prefix of at least one string in the set.Medium5TrieStringNo attempts yet1s1536 MBJudgeable
PasswordsCount ordered pairs of distinct passwords where one string is a substring of the other, treating the passwords as a multiset of short strings.Medium5String matchingHash map+1No attempts yet1s64 MBJudgeable
TypoGiven a dictionary of unique words, print each word that becomes another dictionary word after deleting exactly one character, in input order.Medium5Hash mapString+2No attempts yet6s512 MBJudgeable
Word PuzzleCount how many words from a fixed dictionary can be spelled by paths of adjacent, non-repeating cells in a 5x5 letter grid.Medium6TrieBacktracking+2No attempts yet2s128 MBJudgeable
Beautiful NamesCount the number of orderings of N distinct strings such that all strings sharing a common prefix always form a contiguous block, modulo 1e9+7.Medium6TrieCombinatorics+1No attempts yet1s512 MBJudgeable
Word DivisionCount the number of ways to split a long word (up to length 300,000) into consecutive substrings all belonging to a dictionary of up to 4000 short words, modulo 1337377.Medium6Dynamic programmingString matching+2No attempts yet1s128 MBJudgeable
KokosGiven N words of length 2K, build a trie for the first K letters and a reversed trie for the last K letters and find the minimum vertex count of a graph satisfying strict in/out degree branching-then-merging structure.Medium6TrieString+1No attempts yet1s128 MBJudgeable
Compound WordsGiven a dictionary of up to 120,000 sorted lowercase words, list every word that can be split into two shorter dictionary words.Medium6TrieString+2No attempts yet1s128 MBJudgeable
Card HandsGiven several ordered card hands, merge lists that share a common suffix and report the total number of linked list nodes needed.Medium6TrieString+1No attempts yet1s128 MBJudgeable
Monkeys at TypewritersGiven per-letter and space probabilities, find the probability that a random key sequence terminates at its first space in one of the given words.Medium6ProbabilityTrie+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
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
Villain RobotsChoose a string of K characters over {A,B,C} maximizing the total number of substring occurrences of the given pattern strings.Medium6Dynamic programmingString matching+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
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
BoggleFind all dictionary words on each 4x4 Boggle board with 8-direction steps without reuse, then report the total score, longest word, and word count.Medium6TrieDFS+1No attempts yet10s512 MBJudgeable
Substring Set MembershipYou receive a set of patterns and query strings and print YES for each query containing a pattern as a contiguous substring, NO otherwise.Medium6String matchingTrieNo attempts yet1s256 MBJudgeable
T9Simulate T9 predictive text: map digit presses to dictionary words ordered by frequency, cycle candidates with star, and update frequencies on accept.Medium6TrieSimulation+1No attempts yet1s256 MBJudgeable
IP Address Summarization (Large)The task merges the given IPv4 subnets into the shortest sorted list of normalized subnets covering exactly the same addresses.Medium6TrieBit manipulation+1No attempts yet5s512 MBJudgeable
Garbled Email (Small)Split the received string into dictionary words with changed letters at least 5 apart and as few changes as possible.Medium6Dynamic programmingTrieNo attempts yet30s512 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
Word Puzzle 2Given a 5x5 letter grid and up to 20000 dictionary words, count how many words can be traced through adjacent cells without reusing a cell.Medium6DFSBacktracking+1No attempts yet2s128 MBJudgeable
Maximum XOR of two numbersGiven N non-negative integers, find the maximum XOR over all pairs of distinct elements.Medium6Bit manipulationTrieNo attempts yet2s512 MBJudgeable
CoggleGiven a 5x5 letter grid and a dictionary, count how many dictionary words can be traced through adjacent cells without reusing a cell.Medium6BacktrackingTrie+1No attempts yet1s512 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
HaikuGiven a set of syllables, decide whether the three input phrases can each be split into syllables so their syllable counts are 5, 7, and 5.Medium6Dynamic programmingString+2No attempts yet1s512 MBJudgeable
Gluing PicturesGiven a city string C, find for each friend name the fewest substrings of C that concatenate to form it, or -1 if impossible.Medium6Dynamic programmingString matching+2No attempts yet0.3s512 MBJudgeable
ASCII StreetGiven a street string and multiple pattern tiles, count how many street positions are never covered by any occurrence of any pattern, requiring efficient multi-pattern matching like Aho-Corasick.Medium7String matchingTrie+1No attempts yet4s512 MBJudgeable
Size of the DictionaryCount distinct words formed as base words themselves, plus prefix-of-one-base-word concatenated with suffix-of-another-base-word combinations.Medium7TrieString matching+1No attempts yet2s128 MBJudgeable
DFAGiven a finite set of words, compute the minimum number of states of a DFA recognizing exactly that language.Medium7TrieDynamic programming+1No attempts yet1s128 MBJudgeable
DecipheringCount the ways to split an unspaced text into dictionary words, group them into sentences, and match each sentence to a valid part-of-speech rule, capping the huge counts.Medium7Dynamic programmingString+2No attempts yet2s64 MBJudgeable
CrabblesGiven a dictionary and hands of at most 10 lettered tiles with values, find the maximum-scoring dictionary word formable from each hand's tiles.Medium7TrieBacktracking+2No attempts yet1s128 MBJudgeable
YO!Count paint-over patterns of a short string whose remaining letters, read left to right, form one or more dictionary words without overlap.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Insufficient Disk SpaceGiven files to delete and files to keep, find the minimum number of rm commands (exact or prefix wildcard) to remove all deletable files while keeping the rest.Medium7TrieGreedy+1No attempts yet1s128 MBJudgeable
Type PrinterFind the minimum number of add, remove, and print operations to type N distinct words on a printer that keeps a single editable string, with any print order allowed.Medium7TrieDFS+2No attempts yet1s128 MBJudgeable
Emoticons :-)Given a set of emoticon strings, replace the fewest characters with spaces across several text lines so that no emoticon appears consecutively in any line.Medium7String matchingDynamic programming+2No attempts yet1s128 MBJudgeable
Threatening LetterGiven a newspaper string and a message, split the message into the fewest contiguous pieces, each of which appears somewhere in the newspaper. Output that minimum count.Medium7StringDynamic programming+2No attempts yet1s128 MBJudgeable
Forgotten PasswordFind the lexicographically smallest length-L string that matches a pattern of known letters and '?' and can be written as a concatenation of given dictionary words.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
SubstringsCount the distinct substrings of a string, including the empty string and the whole string, for up to 5000 characters per test case.Medium7StringTrie+2No attempts yet1s128 MBJudgeable
Walk the TalkCount the number of distinct monotone paths (only right and/or up hops) through an H by W letter grid whose visited letters spell one of N given words.Medium7Dynamic programmingTrie+2No attempts yet1s128 MBJudgeable
Color PaletteMaintain a set of K-bit colors under insertions and, for each query color, return the stored color with the maximum number of matching bit positions, breaking ties by smallest value.Medium7TrieBit manipulation+2No attempts yet3s1024 MBJudgeable
ACM-TelecomGiven a prefix table that assigns costs to 8-digit numbers, find the minimum number of prefix rows preserving every number's charged cost.Medium7TrieGreedyNo attempts yet1s128 MBJudgeable
Amusing NumbersGiven K and M, find the smallest N such that K sits at lexicographic position M among the numbers 1 to N.Medium7MathBinary search+2No attempts yet1s128 MBJudgeable
DictionaryGiven a list of words, insert leading spaces so the list satisfies a recursive definition: every maximal run of words sharing a first letter must, after removing the first word and that letter, again be a dictionary.Medium7TrieRecursion+2No attempts yet1s128 MBJudgeable
VirusesGiven a set of forbidden binary words, decide whether an infinite binary sequence exists that avoids all of them as contiguous substrings.Medium7String matchingTrie+2No attempts yet3s512 MBJudgeable
Error CorrectionGiven letter-to-bits codebook and binary strings, decide if exactly one letter sequence encodes to within one bit flip.Medium7Dynamic programmingString matching+1No attempts yet1s128 MBJudgeable
Dividing the namesSplit 2N names into N streets and N avenues so the total length of shortest unique prefixes on all N by N crossing signs is minimal.Medium7TrieDynamic programmingNo attempts yet3s256 MBJudgeable
Barbarian TabletsEach query asks how many words shown so far contain the tablet word of barbarian S as a contiguous substring.Medium7String matchingTrieNo attempts yet4s768 MBJudgeable
XOR SumYou insert numbers into a list and each print query asks for the XOR of the K largest values.Medium7TrieBit manipulationNo attempts yet2s256 MBJudgeable
Number of distinct substrings 2Count how many different contiguous substrings appear in the given lowercase string of length up to 1,000,000.Medium7String matchingSorting+1No attempts yet5s256 MBJudgeable
XORPrint the start and length of the longest contiguous segment whose xor is at least x.Medium7TrieBit manipulation+1No attempts yet5s256 MBJudgeable
OOPCount for each pattern with one asterisk how many given words equal it after replacing the asterisk with any string, possibly empty.Medium7String matchingHash map+1No attempts yet2s512 MBJudgeable
Garbled EmailSplit the garbled string into dictionary words with changed letters spaced at least 5 apart while changing as few letters as possible.Medium7Dynamic programmingTrie+1No attempts yet60s512 MBJudgeable
The Killer Word (Large)Choose the dictionary word that forces the most wrong letter guesses from a guesser who tries letters in a fixed order while ruling out inconsistent words.Medium7TrieSimulation+1No attempts yet5s512 MBJudgeable
Selling RNA StrandsFor each query pair P, Q, count how many dictionary strings start with P and end with Q, where the prefix and suffix may overlap.Medium7TrieString matchingNo attempts yet2s1536 MBJudgeable
Contiguous Subsequence XORCount contiguous subsequences of the given sequence whose bitwise XOR is less than K.Medium7Bit manipulationTrie+1No attempts yet1s512 MBJudgeable
The Witch's PuzzleGiven N words, permute the letters of each word independently and find the minimum number of nodes in the prefix tree (trie) of the resulting set.Medium7TrieDynamic programming+2No attempts yet2s64 MBJudgeable
Largest XOR sum subarrayGiven a sequence, find the maximum XOR value over all contiguous subarrays of length at least one.Medium7Bit manipulationTrie+2No attempts yet10s512 MBJudgeable
CastleMaintain a growing string under appends, insertions of the whole current string into a set, and queries counting how many stored strings are suffixes of the current string.Medium7StringTrieNo attempts yet0.5s256 MBJudgeable
XOR Sum 2Process a stream of insertions and queries, printing the XOR of the K largest stored values.Medium7TrieBit manipulation+2No attempts yet2s512 MBJudgeable
Separate StringCount the ways to split string t into a sequence of pieces, each of which is one of N given dictionary strings, modulo 1e9+7.Medium7Dynamic programmingTrie+2No attempts yet2s512 MBJudgeable
Prefix Free CodeGiven n prefix-free strings, rank a given concatenation of k of them among all ordered k-selections sorted alphabetically, modulo 1e9+7.Medium7TrieCombinatorics+2No attempts yet2s512 MBJudgeable
First of Her NameGiven a family tree where each lady's name is her first letter prepended to her mother's name, count for each query string how many lady names have it as a prefix.Medium7StringTrie+2No attempts yet10s512 MBJudgeable
NVWLSGiven a dictionary of words and a consonant-only message, reconstruct a sentence whose words concatenate to the message after vowels and spaces are removed, maximizing total vowels.Medium7Dynamic programmingString+2No attempts yet6s1024 MBJudgeable
Hidden WordsGiven a grid of up to 10x10 letters and up to 100,000 query words of length at most 10, count how many words can be traced through adjacent, non-repeating cells.Medium7BacktrackingDFS+2No attempts yet2s512 MBJudgeable
Billing TablesGiven an ordered old billing table with range-based prefix rules, build the minimal prefix-only dictionary table (no prefix a prefix of another) that reproduces exactly the same plan decisions for all 11-digit numbers.Hard8TrieGreedy+2No attempts yet1s128 MBJudgeable
Fill the CrosswordFill a crossword grid with a given word list so every slot holds a listed word exactly once and crossings match; also decide if no solution exists.Hard8BacktrackingTrie+2No attempts yet1s128 MBJudgeable
GHOSTGiven a GHOST position and dictionary, decide whether the computer should challenge, add the smallest safe letter, or bluff.Hard8Game theoryTrie+2No attempts yet1s128 MBJudgeable
A-to-ZGiven a word dictionary, for each pair of letters find the minimum total width of a word chain where consecutive words overlap by at least two letters, and the first starts with C1, the last ends with C2.Hard8GraphShortest path+2No attempts yet1s128 MBJudgeable
Spelling SuggestionGiven weighted edit costs including keyboard-aware substitution and transposition, find the dictionary words closest to each query word.Hard8Dynamic programmingString+2No attempts yet12s128 MBJudgeable
Sanghak LanguageCount the distinct strings formed by concatenating any nonempty prefix of a Namgyu word with any nonempty suffix of a Jaehyeok word, summing over several test cases.Hard8TrieString+2No attempts yet1s128 MBJudgeable
File SearchCount how many non-empty subsets of the files can be exactly the result set of some substring query.Hard8StringTrie+2No attempts yet5s128 MBJudgeable
First!Given up to 30000 strings, find every string that can become lexicographically smallest under some permutation of the 26-letter alphabet.Hard8StringTrie+2No attempts yet1s128 MBJudgeable
TreasureGiven a connected graph with N nodes and N edges and max degree 4, count the distinct rooted versions of the graph up to isomorphism, where each root is a non-4-degree node.Hard8GraphTrie+2No attempts yet1s128 MBJudgeable
Word CountingGiven a rooted tree whose edges carry letter strings, count distinct occurrences of a query word along all paths from the root to the leaves, identifying each occurrence by its start and end position.Hard8String matchingTrie+2No attempts yet1s128 MBJudgeable
Tree Rotations 2Given a binary tree with distinct leaf labels, rotations swap children at any node; find the minimum possible inversion count of the leaf sequence.Hard8Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
Fine Dining RestaurantFor each banned serial number, count the digit comparisons the described naive left-to-right substring search performs against the concatenated string A.Hard8String matchingTrie+1No attempts yet3s128 MBJudgeable
DictionaryGiven up to 50 short words, find the fewest vertices of an edge-labeled tree whose downward paths contain every word.Hard8TrieString matching+2No attempts yet1s128 MBJudgeable
Just a QuizTeresa interrupts randomly drawn known questions at chosen words to maximize expected correct answers within t seconds.Hard8Dynamic programmingTrie+1No attempts yet1s256 MBJudgeable
Alphabet Blocks and PasswordsArrange A to Z into the lexicographically smallest permutation with none of the given passwords appearing as a contiguous block.Hard8BacktrackingString matching+1No attempts yet5s512 MBJudgeable