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,789 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Erased Digit SequenceFind the smallest N so K consecutive integers starting at N each contain the corresponding given digit.Medium5Brute forceString+1No attempts yet1s256 MBJudgeable
More or Less AccurateAdd one to each negabinary number in the input and print the result without leading zeros.Medium5MathString+1No attempts yet1s256 MBJudgeable
The Kth Anagram in Alphabetical OrderGiven a word and rank K, print the Kth distinct anagram of the word in alphabetical order.Medium5CombinatoricsStringNo attempts yet1s256 MBJudgeable
Check Amount ValidationCheck whether each English check amount follows the grammar and matches the given digit amount.Medium5StringSimulation+1No attempts yet1s256 MBJudgeable
Permutation with no spacesRecover the permutation from 1 to N whose decimal forms concatenate to the given digit string, choosing the lexicographically smallest one on ties.Medium5BacktrackingBrute force+1No attempts yet1s256 MBJudgeable
Ancient Dictionary OrderDecide whether some alphabet order makes each given word list sorted lexicographically.Medium5Topological sortGraph+1No attempts yet8s256 MBJudgeable
Song TitlesRearrange each title into the lexicographically smallest anagram with no equal adjacent letters, or report IMPOSSIBLE when none exists.Medium5GreedyHeap+1No attempts yet1s256 MBJudgeable
Easy ArithmeticInsert extra plus and minus signs between the digits of the given expression so the resulting valid expression has the largest possible value.Medium5GreedyStringNo attempts yet2s256 MBJudgeable
Each digit at most twiceFind the largest integer L not greater than U whose decimal digits each appear at most twice.Medium5BacktrackingGreedy+1No attempts yet3s256 MBJudgeable
The RepeaterEqualize N lowercase strings using only adjacent duplicate insertions and deletions with the fewest moves, or report impossibility.Medium5StringSorting+1No attempts yet5s512 MBJudgeable
The Repeater (Large)Decide whether N lowercase strings can be made identical by duplicating or deleting adjacent equal letters, and report the fewest moves.Medium5StringSorting+1No attempts yet5s512 MBJudgeable
Consonants (Large)Count the substrings of each given name that contain at least n consecutive consonants.Medium5StringCombinatoricsNo attempts yet5s512 MBJudgeable
Recycled Numbers (Large)Count pairs n < m in [A, B] with equal digits where m is a rotation of n with no leading zero, counting each pair once.Medium5StringBrute force+1No attempts yet5s512 MBJudgeable
The Killer Word (Small)Pick the dictionary word that makes Sean miss the most guesses under his order-based guessing rule, breaking ties by dictionary order.Medium5SimulationString+1No attempts yet5s512 MBJudgeable
Irregular Expressions (Large)Decide if any substring of each string splits into equal start and end words of two or more syllables around a middle word.Medium5Brute forceString+1No attempts yet5s512 MBJudgeable
Decision Tree (Large)Parse a nested decision tree with optional feature names, then multiply node weights along the path chosen by each animal's features.Medium5StringRecursion+2No attempts yet5s512 MBJudgeable
Counting welcome to code jam subsequencesCount subsequences of each input text that spell the 19-character target string, printed as the last four digits.Medium5Dynamic programmingStringNo attempts yet5s512 MBJudgeable
Color Wheel (Small)Repaint a circular string of R, G, B cells K times by a local rule, then report the final count of each color.Medium5SimulationString+1No attempts yet1s256 MBJudgeable
String TheoryGiven alternating runs of quote characters, find the largest k for which the whole string is a k-quotation.Medium5Dynamic programmingString+1No attempts yet2s512 MBJudgeable
Name GeneratorSplit a string into k different non-empty consecutive parts, or report that no such split exists, choosing the lexicographically smallest sequence.Medium5StringGreedy+1No attempts yet2s256 MBJudgeable
A and B 2Given two strings of A and B, decide whether repeatedly appending A or appending B then reversing can turn S into T.Medium5StringGreedy+2No attempts yet2s512 MBJudgeable
Nice PairsCount pairs (x, y) with A <= x < y <= B where y is a rotation of x's digits (a suffix moved to the front), counting duplicates only once.Medium5StringMath+2No attempts yet2s512 MBJudgeable
DucksSplit a string of q,u,a,c,k into the fewest interleaved subsequences, each reading as 'quack' repeated.Medium5GreedySimulation+1No attempts yet2s512 MBJudgeable
Palindromic substringsCount length-N uppercase strings whose length-M substrings include at least K palindromes.Medium5Brute forceString+2No attempts yet2s512 MBJudgeable
Turning A into BGiven two equal-length uppercase strings A and B, find the minimum number of moves that bring a chosen character to the front of A so that A becomes B, or -1 if impossible.Medium5StringGreedy+2No attempts yet2s512 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
Secret PasswordGiven two length-N sequences, decide whether one is a cyclic rotation of the other.Medium5String matchingArray+2No attempts yet1s64 MBJudgeable
Bits EqualizerGiven S with 0, 1, ? and T with 0 and 1, find the fewest moves (0 to 1, ? to 0 or 1, swap two positions) to turn S into T, or -1.Medium5GreedyString+2No attempts yet2s512 MBJudgeable
Hamming EllipsesCount words of length n over a q-symbol alphabet whose Hamming distances to two given words sum to exactly D.Medium5CombinatoricsMath+2No attempts yet5s512 MBJudgeable
Hidden AnagramsGiven two lowercase strings s1 and s2, find the maximum length of a substring of s1 that is an anagram of some substring of s2.Medium5Hash mapString+2No attempts yet10s512 MBJudgeable
Othello RearrangementGiven two length-N strings of W and B, find the minimum number of swap-two-positions and flip-one-piece operations to turn the start into the target.Medium5GreedyMath+1No attempts yet2s256 MBJudgeable
Tangsuyuk GameGiven a word of distinct letters, find the shortest memorized cyclic string each player repeats to always say the correct next letter.Medium5StringMath+1No attempts yet1s128 MBJudgeable
Short Story ContestGiven words, a max line width C, and max lines per page L, find the fewest pages when each line is packed greedily left to right.Medium5GreedyString+1No attempts yet2s512 MBJudgeable
Erasing and WinningGiven an N-digit number and D, erase exactly D digits so the remaining digits, in order, form the largest possible number. Multiple test cases until 0 0.Medium5GreedyStack+2No attempts yet2s512 MBJudgeable
Alphabet StringInsert the fewest lowercase letters into s so that deleting some letters leaves exactly a through z in order.Medium5Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Cutting into three piecesDecide whether the second string can be cut into three non-empty pieces and reordered to equal the first string, printing the shortest-first valid split.Medium5StringBrute force+1No attempts yet0.2s256 MBJudgeable
AbbreviationScan a text and replace each maximal run of two or more single-capitalized words separated by single spaces with their initials followed by the original run in parentheses.Medium5StringSimulation+2No attempts yet1s512 MBJudgeable
Credit Card RecoveryGiven a 16-digit encrypted string, find all original card numbers that the given encrypt rule (bump min up, max down, swap) would produce, printed in ascending order or banana.Medium5Brute forceImplementation+2No attempts yet1s128 MBJudgeable
HackerBuild the minimal list of URLs that covers every known parameter with every malicious value, packing pairs into queries of at most P parameters by the given grouping rule.Medium5ImplementationString+2No attempts yet1s128 MBJudgeable
Cities and StatesGiven up to 200,000 cities with names and two-letter state codes, count unordered pairs whose first two name letters match the other city's state code and vice versa, with different states.Medium5Hash mapString+2No attempts yet2s512 MBJudgeable
DNA stringGiven a DNA string S, find the shortest string over A, C, G, T that never occurs as a contiguous substring of S, breaking ties lexicographically.Medium5StringString matching+1No attempts yet2s512 MBJudgeable
Phone Number Riddle (Small)Given a shuffled string formed from the English words of a phone number's digits, recover the digits, which are guaranteed to be in ascending order.Medium5StringHash map+2No attempts yet5s512 MBJudgeable
Phone Number Riddle (Large)A shuffled concatenation of the English words for a phone number's digits is given; recover the digits, which are in ascending order.Medium5StringHash map+2No attempts yet5s512 MBJudgeable
The Last Word (Small)Given a string S, insert each letter at the front or back of the word as it arrives, and find the alphabetically largest word obtainable.Medium5GreedyString+2No attempts yet5s512 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
Tidy Numbers (Large)Given N up to 10^18, find the largest number not exceeding N whose decimal digits are in non-decreasing order.Medium5GreedyMath+2No attempts yet5s512 MBJudgeable
Unicorn Stable ArrangementGiven counts of red, yellow, and blue unicorns, arrange them in a ring so no two neighbors share a hair color, or report IMPOSSIBLE, printing the lexicographically smallest valid string.Medium5GreedyImplementation+2No attempts yet5s512 MBJudgeable
Hamming distance queriesGiven binary strings a and b, answer queries asking for the Hamming distance between a substring of a and a substring of b.Medium5Prefix sumString+2No attempts yet6s512 MBJudgeable
SlurpyDecide whether each uppercase string is a Slurpy, meaning a Slimp immediately followed by a Slump, where both are defined by recursive grammar rules.Medium5RecursionString+2No attempts yet2s512 MBJudgeable
Rock Paper Scissors MachineGiven two RPS strings, choose where in the opponent's longer string to start matching your shorter string and report the most wins.Medium5StringString matching+2No attempts yet1s512 MBJudgeable
Hangul LCSGiven two Hangul strings of up to 1000 characters each, compute the length of their longest common subsequence in characters.Medium5Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Counting a^i b^j c^k subsequencesCount subsequences of a string of a, b, c that read as some positive number of a's, then b's, then c's, modulo 1e9+7.Medium5Dynamic programmingString+1No attempts yet2s512 MBJudgeable
QueryreuQMaintain a string under append and pop-back operations, and after each operation print the number of palindromic substrings it contains.Medium5StringDynamic programming+2No attempts yet1s1024 MBJudgeable
Pen Pineapple Apple PenGiven a string of A, P, and p, find the maximum number of disjoint subsequence occurrences of the pattern p, P, A, p in order.Medium5GreedyString+1No attempts yet1s32 MBJudgeable
SignalDecode a 5-row pixel strip into digits: 3-column glyphs except 1, separated by blank columns.Medium5ImplementationArray+1No attempts yet1s512 MBJudgeable
PPAPDecide whether a length-1000000 string of P and A is generated from P by replacing a P with PPAP at each step.Medium5StackString+1No attempts yet1s512 MBJudgeable
Demerit Points (DemeritPoints)Simulate a student's demerit events encoded as base-36 chars, tracking accumulated points and quotient-by-10 crossing, and output total expulsion weeks plus weapon or permanent marker.Medium5SimulationString+2No attempts yet0.1s32 MBJudgeable
Engineering CalculatorEvaluate an integer arithmetic expression with precedence, right-associative exponentiation and square root, and truncation toward zero for incomplete roots and divisions.Medium5RecursionMath+2No attempts yet1s256 MBJudgeable
BlogGiven a string of R, G, and B, find the minimum number of contiguous same-color paint operations needed to build it.Medium5Dynamic programmingString+2No attempts yet1s256 MBJudgeable
Longest Increasing Palindromic SubsequenceGiven up to 10^5 integers, find the longest contiguous subarray that is a palindrome whose values strictly rise from both ends toward the center.Medium5StringTwo pointers+1No attempts yet1.5s512 MBJudgeable
I Have Few Friends (Large)Find whether keyword K appears in S as an exact substring, digits and all, and print 1 or 0.Medium5String matchingString+1No attempts yet1s128 MBJudgeable
GCC Min Max ExpressionEvaluate an expression containing the <? (min) and >? (max) operators plus + and -, respecting precedence, left associativity, and parentheses.Medium5StackImplementation+2No attempts yet1s1024 MBJudgeable
H to OCount each atom's total from the input formula multiplied by k and from the output formula, then divide each element's counts to find the smallest quotient, the output count.Medium5StringHash map+2No attempts yet1s512 MBJudgeable
FluteGiven four scrambled lamp grids whose lit lamps may include burned-out (dark) ones, output the earliest valid time matching each grid as a digit pattern.Medium5ImplementationBrute force+1No attempts yet1s512 MBJudgeable
Making a PalindromeFind the largest odd-length palindrome centered at index i, then answer each query by dropping the rest of the N cards.Medium5String matchingDynamic programming+1No attempts yet1s512 MBJudgeable
PokegeneCount, for each query, how many string prefixes occur in exactly L of the K listed genomes.Medium5StringString matching+1No attempts yet2s512 MBJudgeable
Binary StringDelete the fewest bits from a binary string so the remaining subsequence keeps no leading zeros and has value at most K.Medium5StringGreedy+2No attempts yet0.5s512 MBJudgeable
Hard DriveBuild a length-n bit string where fixed-zero positions stay zero, bit 1 and bit n are pinned, and the number of adjacent bit changes is exactly c.Medium5GreedyImplementation+1No attempts yet2s512 MBJudgeable
Email DestructionGiven n, k and k distinct shuffled email subjects of repeated 'Re: ' prefixes plus letters, decide whether exactly n emails could have existed before deletion.Medium5StringHash map+1No attempts yet3s512 MBJudgeable
MagnusDelete any letters from a length-N uppercase word so the kept letters contain as many disjoint subsequences "HONI" as possible, and print that maximum.Medium5GreedyString+1No attempts yet1s512 MBJudgeable
JuniorGiven names in birth order with optional junior or iii suffixes, count people who have no earlier possible parent under the naming rules, which is the number of families.Medium5Hash mapString+1No attempts yet2s512 MBJudgeable
String GuessingGiven all 2N-2 prefixes and suffixes of a hidden string, recover the string and label each input line as prefix or suffix in order.Medium5StringHash map+2No attempts yet2s512 MBJudgeable
Bowling Score CalculationGiven a string describing each ball's result in a 10-frame bowling game (S for strike, P for spare, - for zero, digits otherwise), compute the final score using strike and spare bonus rules.Medium5SimulationImplementation+2No attempts yet1s256 MBJudgeable
Making the Number NCount how many digit-by-digit sequences build the number N when each new digit is attached to the left or right end.Medium5Dynamic programmingString+2No attempts yet1s256 MBJudgeable
StringsBuild strings by concatenating earlier strings or slicing a substring, then output the sum of ASCII codes of the final string modulo 1e9+7, without materializing the possibly huge string.Medium5Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Summer TripGiven a string of event types, count contiguous substrings of length at least two whose first and last characters are distinct and each appears only once in the substring.Medium5StringTwo pointers+2No attempts yet3s1024 MBJudgeable
PalindromeFor each string, print 0 if it is a palindrome, 1 if deleting one character makes it a palindrome, or 2 otherwise.Medium5StringTwo pointers+2No attempts yet1s512 MBJudgeable
Efficient ExchangeGiven a payment amount, minimize the total number of power-of-10 coins exchanged in both directions, allowing both sides to give change.Medium5Dynamic programmingGreedy+2No attempts yet3s512 MBJudgeable
Jinsu's Daily RoutineGiven N and a binary string B with '?' wildcards, and A = 2^N - 1 (all ones), find the maximum and minimum bit-lengths of A*B over all replacements of the '?'.Medium5GreedyString+2No attempts yet2s256 MBJudgeable
What Does UNIST Stand For?Count ways to pick a prefix of each of N words so the concatenation spells UNIST, modulo 1e9+7.Medium5Dynamic programmingString+2No attempts yet1s512 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
Drop The Byte!Given a hex string and a sequence of type sizes (char 2 digits, int 8, long_long 16), split the string and print each piece as a decimal value.Medium5ImplementationString+2No attempts yet1s256 MBJudgeable
HowlGiven a valid howl over A, H, O, W, construct a valid howl that is strictly longer, or report that none exists.Medium5StringGreedy+2No attempts yet1s512 MBJudgeable
Levenshtein DistanceGiven an alphabet and a string s, list every distinct string over that alphabet whose Levenshtein distance from s is exactly 1, sorted alphabetically.Medium5StringBrute force+2No attempts yet1s512 MBJudgeable
Rainbow StringsCount subsequences of a string in which no letter repeats, distinguishing them by position, modulo 11092019.Medium5Dynamic programmingMath+2No attempts yet1s512 MBJudgeable
Alphabet AnimalsGiven the previous animal and a list of unused names, pick a playable name that leaves the next player with no valid move, preferring that over any playable name.Medium5Hash mapImplementation+2No attempts yet2s512 MBJudgeable
Word MemorizationTrack which letters are currently remembered and, after each forget or recall query, report how many dictionary words contain only remembered letters.Medium5Bit manipulationHash map+2No attempts yet4s1024 MBJudgeable
Reversing StringsFor each string choose to reverse it or not so the sequence becomes lexicographically sorted, and output the lexicographically smallest such 0-1 choice string.Medium5GreedyString+2No attempts yet1s256 MBJudgeable
How Many TestsGiven some surviving file names (equal length, digits only), find the minimum and maximum possible original test count n consistent with the zero-padding naming rule.Medium5ImplementationMath+2No attempts yet1s512 MBJudgeable
Different digitsGiven n up to 10^18, find the smallest integer strictly greater than n whose decimal digits have no two adjacent equal digits.Medium5GreedyMath+2No attempts yet1s512 MBJudgeable
Olympiad RegistrationEach row was written in one of two field orders; use the guarantee that every first name appears at least twice to recover each participant's surname, given name, and patronymic, then sort by surname.Medium5Hash mapString+2No attempts yet2s512 MBJudgeable
Making WordsFor each 3x3 letter board, find which center letters yield the fewest and the most dictionary words of length 4 or more, along with those counts.Medium6StringBit manipulation+2No attempts yet1s128 MBJudgeable
String DistanceGiven strings O and N, find the minimum number of substring-insertion operations to turn O into N, or output -1 if impossible.Medium6Dynamic programmingString+2No attempts yet2s128 MBJudgeable
Can You Do Arithmetic?Parse and evaluate an arithmetic expression with +,-,*,/ and parentheses, respecting precedence, and print ROCK if the expression is invalid or divides by zero.Medium6StringStack+2No attempts yet2s128 MBJudgeable
String DecorationGiven N words that can each be cut into ordered pieces and interleaved freely, find the lexicographically smallest concatenation of all pieces.Medium6GreedyString+1No attempts yet1s128 MBJudgeable
Composite PrimeGiven up to 1e5 queries with N as large as 10^7, find the largest composite number at most N whose every proper contiguous digit substring of length 2 or more is prime.Medium6BacktrackingMath+2No attempts yet1s1024 MBJudgeable
Next Palindrome NumberGiven a positive integer with up to 50 digits, construct the smallest palindrome number strictly greater than it.Medium6StringMath+2No attempts yet2s128 MBJudgeable
Password Attempt CountGiven a fixed alphabet order and a password, compute the attempt number at which that string appears in the length-then-lexicographic enumeration, modulo 900528.Medium6MathString+2No attempts yet2s128 MBJudgeable
God of NumbersChoose N numbers from K given natural numbers, using every distinct input at least once, and arrange them to concatenate into the largest possible number.Medium6GreedySorting+1No attempts yet2s128 MBJudgeable
Card PlacementAssign N cards with numbers and letters to N ordered bins under a numeric constraint to build the lexicographically smallest string, or report impossibility.Medium6GreedySorting+2No attempts yet2s128 MBJudgeable