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,787 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Prefix Reversal 3Given a string, for each prefix length from 1 to N in order you may choose to reverse that prefix, and you must output the lexicographically smallest string achievable after all choices.Medium6StringGreedy+2No attempts yet2s128 MBJudgeable
Deleting DigitsGiven a digit string and a required count of each digit to delete, remove exactly that many occurrences of each digit to leave the numerically largest possible string.Medium6GreedyStack+2No attempts yet2s128 MBJudgeable
Periodic PrefixesFor each prefix of a string, find the largest count n such that the prefix is some substring repeated n times, using prefix-function techniques.Medium6String matchingString+1No attempts yet2s128 MBJudgeable
Palindrome PartitioningGiven an uppercase string up to length 2500, compute the minimum number of pieces to cut it into palindromic substrings.Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
Making a NumberGiven how many cards exist for each digit 0-9, build the largest possible number using some or all cards so that no two adjacent digits match and no leading zero appears.Medium6GreedyString+1No attempts yet2s128 MBJudgeable
Anti-PalindromeRearrange all characters of a string to form the lexicographically smallest anti-palindrome, where each pair of symmetric positions must differ, or report impossible.Medium6GreedyString+2No attempts yet2s128 MBJudgeable
Artist Lee DonghoGiven a black/white grid and a limit on horizontal single-color brush strokes, find the minimum number of cells that end up unpainted or wrongly colored.Medium6Dynamic programmingPrefix sum+2No attempts yet2s128 MBJudgeable
Substitution Sequence Range CountsCount occurrences of 1, 2, 3 in a fixed interval of a sequence generated by simultaneous ternary substitution after N steps, without building the whole sequence.Medium6RecursionDivide and conquer+2No attempts yet2s128 MBJudgeable
Making the Best Phone NumberSplit a digit string into groups of 2 or 3 to maximize a score based on group types, then output the lexicographically smallest optimal formatting.Medium6Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Longest Repeated SubstringFind the length of the longest substring that occurs at least twice in a given string of up to 200,000 lowercase letters.Medium6Binary searchString matching+2No attempts yet2s128 MBJudgeable
XYZ StringGiven a self-similar X/Y/Z rewriting sequence, answer queries about the stage N string's length, its k-th character, or the count of a given character without building the full string.Medium6RecursionDivide and conquer+2No attempts yet2s128 MBJudgeable
Resident Registration NumberGiven a 19-digit ID pattern with some digits erased, count completions that form a valid birth date and satisfy the modular checksum rule for the last digit.Medium6CombinatoricsMath+2No attempts yet2s128 MBJudgeable
Colored SticksGiven colored-end sticks, decide if they can all be joined into one line where touching ends share the same color, which reduces to checking an Eulerian path exists.Medium6Union-findGraph+2No attempts yet2s128 MBJudgeable
CubeditorGiven a lowercase string of length up to 5000, find the maximum length of a substring that occurs at least twice, allowing overlapping occurrences.Medium6StringDynamic programming+1No attempts yet0.5s128 MBJudgeable
Mirror NumbersCount how many numbers between A and B (up to 10^18) read the same when reflected in a mirror, using only digits 0,1,2,5,8 with 2 and 5 swapped.Medium6CombinatoricsString+2No attempts yet1s64 MBJudgeable
Strange KeyboardGiven a string on a cursor-based keyboard, find the minimum Left/Right/Enter presses needed to print every character in alphabetical order.Medium6Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
Paper FoldingGiven a crease pattern of length 2^N-1, decide if it could arise from repeatedly folding the right half of a strip onto the left half.Medium6Divide and conquerRecursion+2No attempts yet2s128 MBJudgeable
Adjacent MastermindGiven pairs of target and guess letter strings, compute black, grey, and white Mastermind scores by matching exact, then adjacent, then distant letters in priority order.Medium6StringGreedy+2No attempts yet1s128 MBJudgeable
Greatest Common Divisor of OnesGiven the digit counts N and M of two repunits, print their GCD, which equals the repunit with gcd(N,M) ones, requiring big-number output construction.Medium6Number theoryMath+1No attempts yet2s256 MBJudgeable
Word GameGiven a string and a dictionary of words, find the minimum number of characters to delete from the string so the rest is a concatenation of dictionary words in order.Medium6Dynamic programmingString matching+2No attempts yet2s128 MBJudgeable
Roman Numeral SentencesFind the largest number whose canonical Roman numeral form can be picked out as an in-order subsequence of letters from a given sentence.Medium6GreedyString matching+2No attempts yet2s128 MBJudgeable
Caesar CipherGiven a custom alphabet order, plaintext word, and cipher text, find all shift values for which decrypting yields the word exactly once, using string matching over a large alphabet.Medium6String matchingString+1No attempts yet2s256 MBJudgeable
Logical ExpressionsParse a custom logical expression grammar with user-defined unary and binary operator truth tables, then evaluate it to true, false, or unknown given partial variable assignments.Medium6RecursionString+2No attempts yet1s128 MBJudgeable
Digital FriendsGiven three pairs of huge integers, classify each pair as friends, almost friends, or nothing based on digit-set equality achievable by at most one adjacent digit transfer operation.Medium6StringBrute force+1No attempts yet2s128 MBJudgeable
Cascading WindowsParse windows with titles from an ASCII screen, sort them by title, and redraw them cascaded diagonally from the top-left corner.Medium6SimulationString+2No attempts yet2s128 MBJudgeable
Restoring Calculation ExpressionsInsert +, -, or * between digits of a string (length up to 9, no leading zero numbers) to produce all expressions evaluating to 2000, sorted lexicographically.Medium6BacktrackingBrute force+1No attempts yet1s128 MBJudgeable
Necklace SequenceDecompose a binary string into a strictly decreasing sequence of Lyndon-like necklace factors where adjacent concatenations fail the necklace property.Medium6StringGreedy+1No attempts yet2s128 MBJudgeable
Palindrome PartitionGiven a lowercase string up to length 2000, find the minimum number of palindromic substrings it can be partitioned into.Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
Shortest Uncommon SubsequenceGiven two strings, compute the length of the shortest subsequence of A that is not a subsequence of B.Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
Binary NumberGiven N up to 1000, count consecutive-zero groups in the N-th generation of the Thue-Morse-like doubling sequence without building the exponentially large string.Medium6StringMath+1No attempts yet2s128 MBJudgeable
GPS EncodingGiven a letter permutation encoding numbers 0-25, find the shortest way to encode a digit string as letters using single digits or valid two-digit pairs, breaking ties by lexicographically largest result.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Conflicting StringsDecide, for each set of equal-length strings with wildcard '*', whether removing at most k strings can make every position agree on one letter.Medium6GreedyString+1No attempts yet1s128 MBJudgeable
GeneFind the maximum-length subsequence of a DNA string that can be built by the given nested and concatenated matching-pair grammar (like balanced parentheses with a/t and g/c pairs).Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
String ReconstructionCount length-L strings over an alphabet such that every length-k substring belongs to a given allowed set, solved via automaton/DP over overlaps.Medium6Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Minimum Edit Distance 2Compute the minimum number of insert, delete, replace, and adjacent-swap operations to transform string X into string Y.Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
Keyboard TypoSimulate 2-beolsik Korean keyboard input composition rules to find the position of the first character that breaks valid syllable formation.Medium6SimulationImplementation+1No attempts yet2s128 MBJudgeable
Secret SharingConcatenate all given digit strings in the order that yields the smallest possible integer without a leading zero, or print INVALID if impossible.Medium6GreedyString+1No attempts yet2s128 MBJudgeable
Median StringGiven three equal-length strings, construct a string minimizing the maximum Hamming distance to all three and output that minimum radius.Medium6GreedyString+1No attempts yet1s128 MBJudgeable
DNA SimilarityFind substrings of two DNA sequences that maximize a local sequence-alignment score with custom match and mismatch/gap penalties, and output the score and substrings.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
Good SequenceConstruct the lexicographically smallest square-free string of length N over the alphabet {1,2,3} (no two adjacent equal-length substrings identical).Medium6GreedyString+1No attempts yet1s128 MBJudgeable
QR DecodingParse a 19-byte QR data payload bit by bit and decode its numeric, alphanumeric, byte, and kanji mode segments into a formatted output string.Medium6Bit manipulationString+2No attempts yet1s128 MBJudgeable
Hanging MonkeysParse a nested bracket string representing a binary vine structure and compute the minimum monkeys needed so every split has equal counts on both sides.Medium6RecursionString+2No attempts yet1s128 MBJudgeable
Tax Note XML ConversionParse shorthand tax notes with rate, end month/year, and start month/day, then output valid entries as strict XML or mark ambiguous or invalid lines as bad data.Medium6StringImplementation+1No attempts yet1s128 MBJudgeable
Logical Expression EquivalenceParse two concatenated boolean expressions with C-style operator precedence and decide if they are logically equivalent for all variable assignments.Medium6StringBrute force+1No attempts yet1s128 MBJudgeable
DNA DiscoveryGiven a binary string, find the minimum number of single-character flips or whole-prefix flips needed to turn every character into A.Medium6GreedyDynamic programming+1No attempts yet1s128 MBJudgeable
Square CrosswordCount distinct ways to pick four distinct equal-length words to fill a square crossword so top/bottom rows and left/right columns match corner letters.Medium6Hash mapBrute force+2No attempts yet1s128 MBJudgeable
New Language Alphabet OrderGiven a sorted list of words in an unknown alphabet, reconstruct the unique letter order or report impossibility or ambiguity.Medium6Topological sortGraph+1No attempts yet1s128 MBJudgeable
Bored JungyuGiven XOR values of a lowercase/period/space plaintext with a digit key, decide for each position whether the original was a letter or a period/space.Medium6Bit manipulationBrute force+1No attempts yet1s128 MBJudgeable
Roman Numeral RearrangementGiven a Roman numeral for a number under 100, rearrange all its characters to form the valid Roman numeral with the smallest possible value.Medium6Brute forceString+2No attempts yet1s128 MBJudgeable
Valid Bracket StringsCount ways to replace question marks in a bracket string with one of three bracket types so it becomes a valid nested bracket sequence, output last five digits.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
Dot Matrix PrinterGiven a string, find the minimum number of SET/NEXT/WRITE printer commands needed to output it, where NEXT temporarily overrides the next WRITE.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Hangman GameGiven a hidden word, find the order to select each distinct letter starting from A on a circular alphabet dial that minimizes total LEFT/RIGHT/OK button presses.Medium6Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Geographic MapGiven a grid with village markers 'x' and horizontal uppercase name strings, match each village to its adjacent name using adjacency and uniqueness constraints, then output village positions and names.Medium6ImplementationString+1No attempts yet1s128 MBJudgeable
Lazy TelegraphFor each dictionary word to be sent, find a same-length string minimizing total transmission time (dots=1s, dashes=2s) so that it is the unique closest dictionary word by Hamming distance, then sum the minimum times.Medium6Brute forceString+2No attempts yet1s128 MBJudgeable
Hyunju and Yunju's Fun Word GameCount unordered word pairs (A,B) where A<B lexicographically but reverse(B)<reverse(A), given up to 100,000 distinct words.Medium6SortingString+2No attempts yet1s128 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
Password Name FinderFind the minimum set of 2 to 5 distinct girl names of length 3 to 8 whose pairwise concatenations reconstruct all given passwords.Medium6StringBacktracking+1No attempts yet1s128 MBJudgeable
Two Subsequences 2Given two strings A and B of length up to 2000, find the shortest string that is a subsequence of A but not a subsequence of B.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Bar CodeReconstruct the unique binary digit sequence from a partially unreadable bar code grid of black/white/unknown squares, or report it cannot be determined.Medium6BacktrackingString+1No attempts yet1s128 MBJudgeable
Moore MachineParse a series-parallel Moore machine expression and determine the unique erased output symbol that matches an observed string, or report ambiguity or impossibility.Medium6Dynamic programmingString+2No attempts yet1s128 MBJudgeable
FATBOYFind the longest common subsequence of three given strings, breaking ties by lexicographically smallest result.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
SimilaritySum, over every alignment of a pattern against a text without gaps, the count of matching letter positions, for texts up to 2,000,000 characters.Medium6String matchingString+1No attempts yet1s128 MBJudgeable
BracketsCount, modulo 1e9+9, the ways to turn some matching '(' '(' pairs back into '[' ']' so the bracket string becomes valid with at least one square pair.Medium6Dynamic programmingStack+1No attempts yet1s128 MBJudgeable
MelodyGiven N notes with S-digit codes and a target tune of length L, choose a sequence of notes with adjacent Hamming distance at most G that minimizes total mismatch with the written tune, then output the smallest such sequence lexicographically.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Magic ParenthesisGiven a bracket string with wildcard characters ']' that each consume one or more open parentheses, determine feasibility and output the lexicographically largest assignment of counts for each wildcard.Medium6GreedyStack+1No attempts yet5s128 MBJudgeable
Substitution CipherGiven encrypted words known to be in lexicographic plaintext order and an encrypted message, determine the substitution mapping uniquely if possible and decrypt or report failure.Medium6StringGreedy+1No attempts yet1s128 MBJudgeable
Glass BeadsFind the starting index that produces the lexicographically smallest rotation of a circular string of beads, using an efficient least-rotation algorithm.Medium6StringString matching+1No attempts yet1s128 MBJudgeable
Ideal ContestParse an ASCII contest scoreboard and compute several weighted penalty metrics (vainness, oversimplification, evenness, unsolvability, instability per problem) into a total negidealness score.Medium6ImplementationSimulation+1No attempts yet1s128 MBJudgeable
KenningsExpand a text plan by repeatedly substituting kenning referents with their bodies until reaching a length threshold, then reflow the text to a given line width.Medium6SimulationString+1No attempts yet2s64 MBJudgeable
Please Go FirstGiven a queue string where equal characters denote groups, compute total seconds saved when people yield positions so each group can board together as early as possible.Medium6GreedySimulation+1No attempts yet1s128 MBJudgeable
High ScoreCompute the minimum joystick moves (up/down letter changes and left/right cursor moves, with wraparound) needed to type a target uppercase string starting from all 'A's.Medium6GreedyString+1No attempts yet1s128 MBJudgeable
Common Subexpression EliminationCompress a labeled binary expression tree into a minimal DAG by merging identical subexpressions and print it with backreference numbers to earlier nodes.Medium6Hash mapTree+2No attempts yet1s128 MBJudgeable
Palindrome DateGiven a date, find the next date whose YearMMDD string is a palindrome, handling huge years and leap years correctly.Medium6StringMath+1No attempts yet5s128 MBJudgeable
Computer TransformationGiven n up to 1000, compute the count of adjacent Medium6MathString+1No attempts yet1s128 MBJudgeable
Delta Encoding and DecodingImplement a stateful command interpreter that encrypts, decrypts, or redefines a letter-substitution cipher based on positional value differences, with exact output formatting.Medium6StringImplementation+1No attempts yet1s128 MBJudgeable
Hidden PasswordFind the starting index of the lexicographically smallest rotation of a string, choosing the smallest index in case of ties (Booth's algorithm).Medium6StringString matching+1No attempts yet2s128 MBJudgeable
Turn S into TGiven strings S (with 0,1,?) and T (0,1), compute the minimum number of change/swap operations to transform S into T, or -1 if impossible.Medium6GreedyString+1No attempts yet1s128 MBJudgeable
Production ProcessGiven a matrix chain-like joining table for pieces, find the minimum-time parenthesization to assemble a given string, breaking ties by piece order.Medium6Dynamic programmingString+1No attempts yet5s128 MBJudgeable
The Chemist's MathematicsParse chemical equations with nested parentheses and molecule counts, then solve the resulting linear system to find the minimal positive integer coefficients balancing each element.Medium6MathString+1No attempts yet1s128 MBJudgeable
Confusing Login NamesCompute an extended edit distance (insert, delete, replace, adjacent swap) between all pairs of given login names and output pairs within a given threshold, sorted alphabetically.Medium6Dynamic programmingString+1No attempts yet3s128 MBJudgeable
Suffix Array Re-constructionReconstruct a base string from partial suffix descriptions, where each suffix may contain one wildcard block, and decide when that is impossible.Medium6StringImplementation+2No attempts yet3s128 MBJudgeable
Genetic FraudDecide whether two equal-length strings share an aligned substring of length at least ceil(N/2) where every pair of aligned letters differs by at most 1.Medium6StringTwo pointers+2No attempts yet1s128 MBJudgeable
HackingFind the shortest lexicographically smallest string over the first k letters that appears nowhere as a substring of a given text, with length capped at m.Medium6StringBinary search+2No attempts yet1s512 MBJudgeable
Road SeriesGiven signs of text processed in order, track how far the consecutive count from 1 reaches while remembering seen numbers only within a sliding window.Medium6SimulationHash map+2No attempts yet1s128 MBJudgeable
Decompressing in a GIFDecode a digit string compressed with a simplified GIF LZW scheme, rebuilding the dictionary and tracking when the encoding width grows.Medium6StringHash map+2No 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
Based Integer ConstantsFor each string, decide whether it is a valid Ada integer constant, which may nest a based integer as the base of another based integer.Medium6StringRecursion+1No attempts yet1s128 MBJudgeable
All Your BaseRead two mixed-radix numbers, where digit n (from the right) has base n+1, apply the given addition or subtraction, and print the result in the same system or Invalid.Medium6MathImplementation+2No attempts yet1s128 MBJudgeable
Words and the Periodic TableSplit each word into element symbols, case-insensitively, choosing the split with the fewest parts, then the lowest atomic-number sum.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Phil in the BlanksA puzzle sentence has up to four blanks to fill with number words (zero to one hundred); the filled sentence must correctly count letters, vowels, consonants, or given characters including the inserted words. Count solutions.Medium6Brute forceString+2No attempts yet1s128 MBJudgeable
Schottkey 7th PathGiven files in locations and per-user search paths, return the files matching each request within two extra characters, honoring location priority.Medium6StringImplementation+2No attempts yet1s128 MBJudgeable
Party GamesGiven n distinct uppercase names, find the shortest string S such that exactly half the names are <= S and half are > S, breaking ties by the alphabetically smallest S.Medium6StringSorting+2No attempts yet1s128 MBJudgeable
Generic Units ConversionParse two measurement systems with internal conversion rules, then convert each quantity so every unit of the second system appears with a greedy integer count, rounding the smallest unit.Medium6ImplementationSimulation+2No attempts yet1s128 MBJudgeable
HTML EditorGiven a valid HTML string and a range, output that substring wrapped with the tags needed to preserve its formatting.Medium6StringStack+1No attempts yet1s128 MBJudgeable
ChemistryParse a chemical formula with nested parentheses and multipliers, then output each element's total atom count in lexicographic order.Medium6StackString+2No attempts yet1s128 MBJudgeable
Removing ParenthesesGiven an expression of single-letter variables with addition and multiplication, remove every pair of parentheses that can go without changing the value, and print the result.Medium6StackString+2No attempts yet1s128 MBJudgeable
XML ValidatorDecide for each input line whether it is valid XML: matching open and close tags, allowed plain text, and proper escape sequences.Medium6StringStack+1No attempts yet1s128 MBJudgeable
ResistorsParse a nested expression of series and parallel resistor connections and output the exact resistance as a reduced fraction.Medium6StringStack+2No attempts yet1s128 MBJudgeable