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 results389 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Palindrome CheckCheck whether the given lowercase word reads the same forward and backward and print 1 or 0. | Easy1 | StringTwo pointers | No attempts yet | 1s | 256 MB | Judgeable |
| NumbersrebmunMap each letter of a company name to its phone keypad digit, then check whether the resulting digit string reads the same forwards and backwards. | Easy2 | StringTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Palindrome ColoringSplit each A/B string into the fewest palindromic subsequences and output that count. | Easy2 | StringTwo pointers | No attempts yet | 1s | 128 MB | Judgeable |
| Palindrome LinesDecide for each of n short lines whether it reads the same forward and backward, ignoring letter case. | Easy2 | Two pointersString | No attempts yet | 1s | 256 MB | Judgeable |
| Spring 2005: Arriving at USCFilter the building list to names that hold the abbreviation letters as a case-insensitive subsequence and print the matches in input order. | Easy2 | Two pointersString matching | No attempts yet | 1s | 256 MB | Judgeable |
| Speed ViolationTwo speed profiles split the same 100 km road at different points, and you report the largest amount by which the driven speed exceeds the limit. | Easy2 | Two pointersSimulation | No attempts yet | 2s | 512 MB | Judgeable |
| PalindromeGiven a lowercase word of at most 20 characters, decide whether it reads the same forwards and backwards. | Easy2 | StringTwo pointers+1 | No attempts yet | 2s | 512 MB | Judgeable |
| The Funniest Digital LaughterGiven a string, ignore the consonants and decide whether the remaining vowels read the same forwards and backwards. | Easy2 | StringTwo pointers | No attempts yet | 1s | 512 MB | Judgeable |
| MergeMerge two sorted sequences into one sorted sequence using the given tie-breaking rule, which takes from A when the front elements are equal. | Easy2 | Two pointersImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Switches On and OffSimulate switch toggles where male students flip every multiple of their number and female students flip the largest symmetric interval centered on their number. | Easy3 | SimulationArray+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Make a PalindromeGiven a lowercase string of length at most 50, find the minimum length of a palindrome obtained by appending characters only to its end. | Easy3 | StringBrute force+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Jumong's Armor MaterialsCount how many pairs of given numbers sum to a target value M, using each material at most once per pair. | Easy3 | Two pointersArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Sum of Numbers 2Given N positive integers and a target M, count contiguous subarrays whose sum equals M. | Easy3 | Two pointersPrefix sum+1 | No attempts yet | 0.5s | 128 MB | Judgeable |
| BlackjackGiven N card values and a target M, find the maximum sum of three distinct cards not exceeding M. | Easy3 | Brute forceTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sum of Two NumbersCount pairs of distinct integers in an array that sum exactly to a given value x. | Easy3 | Hash mapTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ShirtsMerge two already sorted lists of shirts and print one merged list ordered by size, then by colour letter. Multiple scenarios end with a 0. | Easy3 | SortingTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Campus BuildingsGiven building names and an abbreviation, list the names whose letters contain the abbreviation as a case-insensitive subsequence, in input order. | Easy3 | StringTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Longest Decreasing SuffixFor each string, print its longest suffix whose characters strictly decrease from left to right. | Easy3 | StringImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Look-and-Say StringApply the look-and-say run-length encoding to a digit string n times and print the resulting string. | Easy3 | StringImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Costume PartyCount pairs of cows whose lengths sum to at most S. | Easy3 | SortingTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PalindromesFor each string, decide whether it reads the same backward and whether replacing each character by its mirror and reversing gives the same string. | Easy3 | StringImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SubsequenceFor each line of input, decide whether the first string is a subsequence of the second, printing Yes or No. | Easy3 | Two pointersString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Matryoshka DollsGiven doll heights, nest each doll inside a strictly taller doll, each holding at most one, to minimize the number of outermost dolls. | Easy3 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Intelligence TestGiven a fixed sequence and several queries, decide for each query sequence whether it is a subsequence of the fixed sequence. | Easy3 | ArrayTwo pointers+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Two TowersRemove the fewest blocks from the tops of two towers so the remaining towers have equal height. | Easy3 | GreedyTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Garden TroubleFind the longest contiguous segment of the garden that holds at most K chestnut trees. | Easy3 | Sliding windowTwo pointers | No attempts yet | 1s | 128 MB | Judgeable |
| PalindromeFrom the given words, pick two at different positions so their concatenation is a palindrome and report the lexicographically smallest one. | Easy3 | Brute forceString+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Goldbach's ConjectureGiven an even number n, print the two primes that sum to n with the smallest gap between them. | Easy3 | Number theoryTwo pointers | No attempts yet | 2s | 256 MB | Judgeable |
| Virus ReplicationGiven the DNA strands before and after one contiguous replacement, find the shortest inserted piece that explains the change. | Easy3 | StringTwo pointers | No attempts yet | 1s | 128 MB | Judgeable |
| Between the MountainsPick one altitude from each mountain so the absolute difference between the two is as small as possible. | Easy3 | Two pointersSorting | No attempts yet | 1s | 128 MB | Judgeable |
| Pair SumCount pairs in a sorted distinct array that sum to a target M for each test case. | Easy3 | Two pointersArray | No attempts yet | 1s | 128 MB | Judgeable |
| Real Estate AuctionCount the blocks of consecutive houses priced 2, 3, 4 and upward whose prices sum to exactly N. | Easy3 | Sliding windowTwo pointers+1 | No attempts yet | 10s | 256 MB | Judgeable |
| Merging Two Sorted ArraysMerge two sorted arrays into one sorted sequence with a two-pointer walk. | Easy3 | Two pointersArray | No attempts yet | 1.5s | 256 MB | Judgeable |
| Consonants (Small)Count the substrings of each name that contain at least n consecutive consonants. | Easy3 | StringTwo pointers | No attempts yet | 5s | 512 MB | Judgeable |
| Store CreditGiven a credit C and a list of item prices, find the two positions whose prices sum exactly to C and print them in increasing order. | Easy3 | ArrayHash map+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Longest non-decreasing subsegmentFind the longest contiguous non-decreasing run in a list and output its length and the sum of its elements, breaking ties by earliest start. | Easy3 | ArrayImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Card TradeGiven two sorted card piles, find the largest N such that Alice and Beatriz can each give away N cards of distinct kinds that the other does not own. | Easy3 | Two pointersArray+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Palindrome in base nFor each query, convert the decimal number A to base n and report whether its digit sequence reads the same forwards and backwards. | Easy3 | MathImplementation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Number PairsCount pairs of distinct values in a sequence that sum to a target K, where order does not matter and each element is used once. | Easy3 | ArrayHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Olivander's wand boxesGiven N wand lengths and N box sizes, decide whether every wand can be paired with a distinct box whose size is at least the wand length. | Easy3 | SortingGreedy+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Send me the moneyGiven a pattern string S, decide for each of M notes whether S is a subsequence of the note. | Easy3 | StringTwo pointers+2 | No attempts yet | 1s | 512 MB | Judgeable |
| TurnaroundsGiven the seconds when each team scored, report how many points fell in the first half and how many times the lead changed from strictly behind to strictly ahead. | Easy3 | ImplementationSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Claire and PalindromeFill each '?' in a string with a lowercase letter so the whole string becomes a palindrome, printing any valid result. | Easy3 | StringTwo pointers+1 | No attempts yet | 1s | 256 MB | Judgeable |
| SticksGiven the heights of N sticks in a row, count how many sticks are visible when the row is viewed from the right, where a stick is visible only if it is strictly taller than every stick to its right. | Easy3 | ArrayImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Mountain RangesGiven non-decreasing viewpoint altitudes along a trail, find the length of the longest run where each consecutive altitude increase is at most X, starting anywhere. | Easy3 | ArrayTwo pointers+2 | No attempts yet | 0.1s | 512 MB | Judgeable |
| CHROMGiven two parent permutations and two crossover points n and m, build the offspring by keeping parent 1's segment [n, m) in place and filling the rest from parent 2 in order. | Easy3 | ArrayImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Amateur AgronomistFind the longest contiguous segment of a flower row that does not contain three equal values in a row, and print its start and end indices. | Easy3 | ArrayTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Consecutive Prime SumCount how many ways a given N up to 4,000,000 can be written as a sum of one or more consecutive prime numbers. | Medium4 | Sliding windowTwo pointers+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Partial SumFind the minimum length of a contiguous subarray whose sum is at least S, or 0 if none exists. | Medium4 | Sliding windowTwo pointers+1 | No attempts yet | 0.5s | 128 MB | Judgeable |
| Choose Two Numbers With Minimum DifferenceGiven N integers and threshold M, find the minimum absolute difference between two elements that is still at least M. | Medium4 | SortingTwo pointers+1 | No attempts yet | 2s | 128 MB | Judgeable |
| File Similarity ChecksGiven N file sizes, count pairs where the smaller size is at least 0.9 times the larger size. | Medium4 | SortingTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Two Liquids Closest to ZeroGiven a sorted array, find two distinct numbers whose sum is closest to zero using a two-pointer sweep. | Medium4 | Two pointersArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Two LiquidsGiven N distinct integers, sort them and use two pointers to find the pair whose sum is closest to zero. | Medium4 | Two pointersSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Teams with Sum ZeroCount the number of index triples among N students whose skill values sum to exactly zero. | Medium4 | ArrayTwo pointers+1 | No attempts yet | 4s | 128 MB | Judgeable |
| Robot ProjectGiven a target length and up to a million rod lengths, find two rods summing exactly to the target with the maximum length difference, or report impossibility. | Medium4 | Two pointersSorting+1 | No attempts yet | 5s | 256 MB | Judgeable |
| CDGiven two sorted lists of distinct CD numbers, count how many numbers appear in both lists. | Medium4 | Two pointersSorting+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Unique SnowflakesGiven a stream of integer snowflake ids, find the length of the longest contiguous block in which every value is distinct. | Medium4 | Sliding windowHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Dragon of LoowaterMatch the smallest knight to each dragon head so that every head is cut by a tall enough knight, minimizing total height paid; report failure if impossible. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Next PermutationGiven an integer A, find the smallest permutation of its digits that is strictly greater than A, or print USELESS if none exists. | Medium4 | ArrayString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ACApply a string of reverse (R) and discard-first (D) operations to an integer array, printing the result or error if D hits an empty array. | Medium4 | ImplementationArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| The Longest StaircaseGiven k cards with distinct values 1 to n plus one blank card (0) you can set to any value, find the longest run of consecutive integers formable. | Medium4 | SortingTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Meet and GreetSimulate two cows walking along a line at unit speed and count how many times they meet after being apart, excluding the start. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Widest MountainGiven a sequence of heights, find the longest contiguous run that is non-decreasing then non-increasing; valleys are shared by both neighboring mountains. | Medium4 | ArrayImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Mountain WatchingGiven a sequence of heights, find the longest consecutive block that rises (non-strictly) then falls (non-strictly), allowing a block that only rises or only falls. | Medium4 | ArrayTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Word PowerFor each of N cow names, count how many of M good strings appear as a case-insensitive subsequence of the name. | Medium4 | StringTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Buy One Get One FreeBuy all N high quality bales, then pair as many of the M low quality bales as possible so each free bale is strictly smaller than its distinct high quality partner. Output N plus the maximum number of pairs. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum DistanceGiven two non-increasing arrays, find the largest j - i such that j >= i and Y[j] >= X[i]. | Medium4 | ArrayTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Substring ReversalGiven an original string and the result of reversing one substring of length at least two, find the reversed segment, preferring the smallest start then end. | Medium4 | StringTwo pointers | No attempts yet | 1s | 1024 MB | Judgeable |
| Grandpa's Other EstateGiven up to 100 points and a square side length r, place the axis-aligned square to cover as many points as possible, counting border points as inside. | Medium4 | ArraySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| To Eat or Be EatenCount pairs where an A creature is strictly larger than a B creature, given two lists of sizes. | Medium4 | SortingTwo pointers+2 | No attempts yet | 1s | 256 MB | Judgeable |
| CanoesGiven a canoe weight limit and each participant's weight, find the minimum number of two-person canoes needed to carry everyone. | Medium4 | GreedyTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PilotsFind the length of the longest contiguous fragment whose maximum minus minimum is at most t. | Medium4 | Sliding windowTwo pointers+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Digging a WellFind the smallest vertical gap between the ground polyline and the aquifer polyline over their shared x range. | Medium4 | GeometryTwo pointers | No attempts yet | 1s | 128 MB | Judgeable |
| Password ValidationDecide whether each password meets length, character mix, repeat, palindrome, and forbidden subsequence rules. | Medium4 | ImplementationString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Lazy Polar BearChoose a point on the line so the buckets within distance K of it hold the most ice in total. | Medium4 | Sliding windowSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Next permutationGiven a permutation of 1 to N, print the next permutation in lexicographic order, or -1 when the given one is the last. | Medium4 | ArrayTwo pointers | No attempts yet | 1s | 256 MB | Judgeable |
| ExcellencePair all students into teams of two so the smallest team rating sum is as large as possible. | Medium4 | GreedySorting+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Packing Files onto DiscsPack all files onto the fewest discs of capacity X with at most two files per disc. | Medium4 | GreedyTwo pointers+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Data PackingPack files onto discs holding at most two files of total size X using the fewest discs. | Medium4 | GreedyTwo pointers+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Counting Equilateral TrianglesGiven arc lengths around a circle and points at the boundaries, count equilateral triangles whose three vertices are among the points. | Medium4 | Prefix sumMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| PalindromesFor each string, find the leftmost single-character deletion that leaves a palindrome, or report that none exists. | Medium4 | StringTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Taro's ShoppingGiven item prices and a budget, find the largest sum of two distinct items that does not exceed the budget. | Medium4 | Two pointersSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Almost Identical ProgramsGiven two program strings, decide whether they are identical, differ only in one string literal at the same position, or are otherwise different. | Medium4 | StringImplementation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Frosh WeekGiven task durations and quiet-interval lengths, each between 100000 and 199999, pair tasks with intervals that fit them and maximize the number of completed tasks. | Medium4 | GreedyTwo pointers+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Gahui and the 3-Step High NoteGiven a sequence of notes and an arithmetic progression with first term A and difference D, find the largest number of terms of the progression that appear as a subsequence in order. | Medium4 | GreedyArray+2 | No attempts yet | 1.5s | 256 MB | Judgeable |
| KittyFind the longest contiguous substring with at most N distinct lowercase letters. | Medium4 | Sliding windowTwo pointers+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Devil GameFind a dictionary word containing the original word as a subsequence and maximize mood-killing degree per inserted letter, breaking ties by input order. | Medium4 | StringTwo pointers+1 | No attempts yet | 1s | 256 MB | Judgeable |
| The Ups and Downs of InvestingCount price peaks needing n rising and n falling days and valleys needing m falling and m rising days. | Medium4 | ArrayImplementation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Two ArraysFor each element of A, find the element of B closest in value (smallest on ties) and print the sum of these chosen values. | Medium4 | Binary searchSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Feeding SealsEach volunteer can carry one or two buckets as long as their combined weight stays within capacity c. Find the minimum number of volunteers needed to move all buckets. | Medium4 | GreedyTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cargo LoadingGiven crane weight limits and box weights, find the minimum minutes to load all boxes with one box per crane per minute, or -1 if impossible. | Medium5 | GreedySorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Good NumbersGiven N integers, count how many of them equal the sum of two other numbers at two different positions in the sequence. | Medium5 | Two pointersArray+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Paper FoldingDecide whether a strip of N labeled cells can be folded so the stack reads 1 to N from top to bottom, checking labels against the shrinking strip's two ends. | Medium5 | Two pointersSimulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| DuelMatch N Team A fighters against N Team B fighters to maximize points, where a win scores 2, a tie scores 1, and a loss scores 0. | Medium5 | GreedySorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Triangle SubsequenceGiven a sequence, find the longest subsequence where every triple of elements satisfies the triangle inequality. | Medium5 | SortingTwo pointers+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Sum of Three NumbersGiven up to 1000 distinct integers, find the largest set element expressible as a sum of three elements (repeats allowed). | Medium5 | Two pointersSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Three SolutionsGiven up to 5000 distinct integers, find three distinct values whose sum is closest to zero, using sorting and two-pointer scanning. | Medium5 | Two pointersSorting+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Evil Straw Warts LiveFor each string, find the fewest adjacent swaps needed to rearrange it into a palindrome, or report that no palindrome is possible. | Medium5 | GreedyTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RailroadGiven two sequences, decide whether a target sequence can be formed by repeatedly taking the front car of either train; once one train empties, the rest follow in order. | Medium5 | Dynamic programmingTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sequence WalkingGiven two ascending integer sequences, find the maximum sum of a forward walk that may switch sequences at shared values. | Medium5 | Dynamic programmingTwo pointers | No attempts yet | 1s | 128 MB | Judgeable |