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
TitleLevelTopicsSolvedTime limitMemory limitJudge
Palindrome CheckCheck whether the given lowercase word reads the same forward and backward and print 1 or 0.Easy1StringTwo pointersNo attempts yet1s256 MBJudgeable
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.Easy2StringTwo pointers+1No attempts yet1s128 MBJudgeable
Palindrome ColoringSplit each A/B string into the fewest palindromic subsequences and output that count.Easy2StringTwo pointersNo attempts yet1s128 MBJudgeable
Palindrome LinesDecide for each of n short lines whether it reads the same forward and backward, ignoring letter case.Easy2Two pointersStringNo attempts yet1s256 MBJudgeable
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.Easy2Two pointersString matchingNo attempts yet1s256 MBJudgeable
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.Easy2Two pointersSimulationNo attempts yet2s512 MBJudgeable
PalindromeGiven a lowercase word of at most 20 characters, decide whether it reads the same forwards and backwards.Easy2StringTwo pointers+1No attempts yet2s512 MBJudgeable
The Funniest Digital LaughterGiven a string, ignore the consonants and decide whether the remaining vowels read the same forwards and backwards.Easy2StringTwo pointersNo attempts yet1s512 MBJudgeable
MergeMerge two sorted sequences into one sorted sequence using the given tie-breaking rule, which takes from A when the front elements are equal.Easy2Two pointersImplementation+2No attempts yet2s512 MBJudgeable
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.Easy3SimulationArray+2No attempts yet2s128 MBJudgeable
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.Easy3StringBrute force+1No attempts yet2s128 MBJudgeable
Jumong's Armor MaterialsCount how many pairs of given numbers sum to a target value M, using each material at most once per pair.Easy3Two pointersArray+1No attempts yet2s128 MBJudgeable
Sum of Numbers 2Given N positive integers and a target M, count contiguous subarrays whose sum equals M.Easy3Two pointersPrefix sum+1No attempts yet0.5s128 MBJudgeable
BlackjackGiven N card values and a target M, find the maximum sum of three distinct cards not exceeding M.Easy3Brute forceTwo pointers+1No attempts yet1s128 MBJudgeable
Sum of Two NumbersCount pairs of distinct integers in an array that sum exactly to a given value x.Easy3Hash mapTwo pointers+1No attempts yet1s128 MBJudgeable
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.Easy3SortingTwo pointers+2No attempts yet1s128 MBJudgeable
Campus BuildingsGiven building names and an abbreviation, list the names whose letters contain the abbreviation as a case-insensitive subsequence, in input order.Easy3StringTwo pointers+1No attempts yet1s128 MBJudgeable
Longest Decreasing SuffixFor each string, print its longest suffix whose characters strictly decrease from left to right.Easy3StringImplementation+2No attempts yet1s128 MBJudgeable
Look-and-Say StringApply the look-and-say run-length encoding to a digit string n times and print the resulting string.Easy3StringImplementation+2No attempts yet1s128 MBJudgeable
Costume PartyCount pairs of cows whose lengths sum to at most S.Easy3SortingTwo pointers+1No attempts yet1s128 MBJudgeable
PalindromesFor each string, decide whether it reads the same backward and whether replacing each character by its mirror and reversing gives the same string.Easy3StringImplementation+2No attempts yet1s128 MBJudgeable
SubsequenceFor each line of input, decide whether the first string is a subsequence of the second, printing Yes or No.Easy3Two pointersString+2No attempts yet1s128 MBJudgeable
Matryoshka DollsGiven doll heights, nest each doll inside a strictly taller doll, each holding at most one, to minimize the number of outermost dolls.Easy3GreedySorting+1No attempts yet1s128 MBJudgeable
Intelligence TestGiven a fixed sequence and several queries, decide for each query sequence whether it is a subsequence of the fixed sequence.Easy3ArrayTwo pointers+1No attempts yet3s512 MBJudgeable
Two TowersRemove the fewest blocks from the tops of two towers so the remaining towers have equal height.Easy3GreedyTwo pointers+1No attempts yet1s128 MBJudgeable
Garden TroubleFind the longest contiguous segment of the garden that holds at most K chestnut trees.Easy3Sliding windowTwo pointersNo attempts yet1s128 MBJudgeable
PalindromeFrom the given words, pick two at different positions so their concatenation is a palindrome and report the lexicographically smallest one.Easy3Brute forceString+1No attempts yet1s256 MBJudgeable
Goldbach's ConjectureGiven an even number n, print the two primes that sum to n with the smallest gap between them.Easy3Number theoryTwo pointersNo attempts yet2s256 MBJudgeable
Virus ReplicationGiven the DNA strands before and after one contiguous replacement, find the shortest inserted piece that explains the change.Easy3StringTwo pointersNo attempts yet1s128 MBJudgeable
Between the MountainsPick one altitude from each mountain so the absolute difference between the two is as small as possible.Easy3Two pointersSortingNo attempts yet1s128 MBJudgeable
Pair SumCount pairs in a sorted distinct array that sum to a target M for each test case.Easy3Two pointersArrayNo attempts yet1s128 MBJudgeable
Real Estate AuctionCount the blocks of consecutive houses priced 2, 3, 4 and upward whose prices sum to exactly N.Easy3Sliding windowTwo pointers+1No attempts yet10s256 MBJudgeable
Merging Two Sorted ArraysMerge two sorted arrays into one sorted sequence with a two-pointer walk.Easy3Two pointersArrayNo attempts yet1.5s256 MBJudgeable
Consonants (Small)Count the substrings of each name that contain at least n consecutive consonants.Easy3StringTwo pointersNo attempts yet5s512 MBJudgeable
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.Easy3ArrayHash map+2No attempts yet5s512 MBJudgeable
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.Easy3ArrayImplementation+2No attempts yet2s512 MBJudgeable
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.Easy3Two pointersArray+1No attempts yet2s512 MBJudgeable
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.Easy3MathImplementation+2No attempts yet1s256 MBJudgeable
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.Easy3ArrayHash map+2No attempts yet2s512 MBJudgeable
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.Easy3SortingGreedy+2No attempts yet1s64 MBJudgeable
Send me the moneyGiven a pattern string S, decide for each of M notes whether S is a subsequence of the note.Easy3StringTwo pointers+2No attempts yet1s512 MBJudgeable
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.Easy3ImplementationSimulation+2No attempts yet1s512 MBJudgeable
Claire and PalindromeFill each '?' in a string with a lowercase letter so the whole string becomes a palindrome, printing any valid result.Easy3StringTwo pointers+1No attempts yet1s256 MBJudgeable
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.Easy3ArrayImplementation+2No attempts yet1s512 MBJudgeable
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.Easy3ArrayTwo pointers+2No attempts yet0.1s512 MBJudgeable
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.Easy3ArrayImplementation+2No attempts yet2s512 MBJudgeable
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.Easy3ArrayTwo pointers+2No attempts yet2s512 MBJudgeable
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.Medium4Sliding windowTwo pointers+2No attempts yet2s128 MBJudgeable
Partial SumFind the minimum length of a contiguous subarray whose sum is at least S, or 0 if none exists.Medium4Sliding windowTwo pointers+1No attempts yet0.5s128 MBJudgeable
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.Medium4SortingTwo pointers+1No attempts yet2s128 MBJudgeable
File Similarity ChecksGiven N file sizes, count pairs where the smaller size is at least 0.9 times the larger size.Medium4SortingTwo pointers+1No attempts yet1s128 MBJudgeable
Two Liquids Closest to ZeroGiven a sorted array, find two distinct numbers whose sum is closest to zero using a two-pointer sweep.Medium4Two pointersArray+1No attempts yet1s128 MBJudgeable
Two LiquidsGiven N distinct integers, sort them and use two pointers to find the pair whose sum is closest to zero.Medium4Two pointersSorting+1No attempts yet1s128 MBJudgeable
Teams with Sum ZeroCount the number of index triples among N students whose skill values sum to exactly zero.Medium4ArrayTwo pointers+1No attempts yet4s128 MBJudgeable
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.Medium4Two pointersSorting+1No attempts yet5s256 MBJudgeable
CDGiven two sorted lists of distinct CD numbers, count how many numbers appear in both lists.Medium4Two pointersSorting+1No attempts yet1s256 MBJudgeable
Unique SnowflakesGiven a stream of integer snowflake ids, find the length of the longest contiguous block in which every value is distinct.Medium4Sliding windowHash map+2No attempts yet1s128 MBJudgeable
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.Medium4GreedySorting+2No attempts yet1s128 MBJudgeable
Next PermutationGiven an integer A, find the smallest permutation of its digits that is strictly greater than A, or print USELESS if none exists.Medium4ArrayString+2No attempts yet1s128 MBJudgeable
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.Medium4ImplementationArray+1No attempts yet1s256 MBJudgeable
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.Medium4SortingTwo pointers+1No attempts yet1s128 MBJudgeable
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.Medium4SimulationImplementation+2No attempts yet1s128 MBJudgeable
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.Medium4ArrayImplementation+2No attempts yet1s128 MBJudgeable
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.Medium4ArrayTwo pointers+2No attempts yet1s128 MBJudgeable
Word PowerFor each of N cow names, count how many of M good strings appear as a case-insensitive subsequence of the name.Medium4StringTwo pointers+2No attempts yet1s128 MBJudgeable
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.Medium4GreedySorting+2No attempts yet1s128 MBJudgeable
Maximum DistanceGiven two non-increasing arrays, find the largest j - i such that j >= i and Y[j] >= X[i].Medium4ArrayTwo pointers+2No attempts yet1s128 MBJudgeable
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.Medium4StringTwo pointersNo attempts yet1s1024 MBJudgeable
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.Medium4ArraySorting+2No attempts yet1s128 MBJudgeable
To Eat or Be EatenCount pairs where an A creature is strictly larger than a B creature, given two lists of sizes.Medium4SortingTwo pointers+2No attempts yet1s256 MBJudgeable
CanoesGiven a canoe weight limit and each participant's weight, find the minimum number of two-person canoes needed to carry everyone.Medium4GreedyTwo pointers+2No attempts yet1s128 MBJudgeable
PilotsFind the length of the longest contiguous fragment whose maximum minus minimum is at most t.Medium4Sliding windowTwo pointers+1No attempts yet3s128 MBJudgeable
Digging a WellFind the smallest vertical gap between the ground polyline and the aquifer polyline over their shared x range.Medium4GeometryTwo pointersNo attempts yet1s128 MBJudgeable
Password ValidationDecide whether each password meets length, character mix, repeat, palindrome, and forbidden subsequence rules.Medium4ImplementationString+1No attempts yet1s128 MBJudgeable
Lazy Polar BearChoose a point on the line so the buckets within distance K of it hold the most ice in total.Medium4Sliding windowSorting+1No attempts yet1s128 MBJudgeable
Next permutationGiven a permutation of 1 to N, print the next permutation in lexicographic order, or -1 when the given one is the last.Medium4ArrayTwo pointersNo attempts yet1s256 MBJudgeable
ExcellencePair all students into teams of two so the smallest team rating sum is as large as possible.Medium4GreedySorting+1No attempts yet2s256 MBJudgeable
Packing Files onto DiscsPack all files onto the fewest discs of capacity X with at most two files per disc.Medium4GreedyTwo pointers+1No attempts yet5s512 MBJudgeable
Data PackingPack files onto discs holding at most two files of total size X using the fewest discs.Medium4GreedyTwo pointers+1No attempts yet5s512 MBJudgeable
Counting Equilateral TrianglesGiven arc lengths around a circle and points at the boundaries, count equilateral triangles whose three vertices are among the points.Medium4Prefix sumMath+1No attempts yet2s512 MBJudgeable
PalindromesFor each string, find the leftmost single-character deletion that leaves a palindrome, or report that none exists.Medium4StringTwo pointers+2No attempts yet2s512 MBJudgeable
Taro's ShoppingGiven item prices and a budget, find the largest sum of two distinct items that does not exceed the budget.Medium4Two pointersSorting+1No attempts yet2s512 MBJudgeable
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.Medium4StringImplementation+1No attempts yet2s512 MBJudgeable
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.Medium4GreedyTwo pointers+2No attempts yet4s512 MBJudgeable
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.Medium4GreedyArray+2No attempts yet1.5s256 MBJudgeable
KittyFind the longest contiguous substring with at most N distinct lowercase letters.Medium4Sliding windowTwo pointers+1No attempts yet1s512 MBJudgeable
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.Medium4StringTwo pointers+1No attempts yet1s256 MBJudgeable
The Ups and Downs of InvestingCount price peaks needing n rising and n falling days and valleys needing m falling and m rising days.Medium4ArrayImplementation+1No attempts yet2s512 MBJudgeable
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.Medium4Binary searchSorting+2No attempts yet2s512 MBJudgeable
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.Medium4GreedyTwo pointers+2No attempts yet2s512 MBJudgeable
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.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
Good NumbersGiven N integers, count how many of them equal the sum of two other numbers at two different positions in the sequence.Medium5Two pointersArray+1No attempts yet2s256 MBJudgeable
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.Medium5Two pointersSimulation+1No attempts yet2s128 MBJudgeable
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.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
Triangle SubsequenceGiven a sequence, find the longest subsequence where every triple of elements satisfies the triangle inequality.Medium5SortingTwo pointers+1No attempts yet2s128 MBJudgeable
Sum of Three NumbersGiven up to 1000 distinct integers, find the largest set element expressible as a sum of three elements (repeats allowed).Medium5Two pointersSorting+1No attempts yet1s128 MBJudgeable
Three SolutionsGiven up to 5000 distinct integers, find three distinct values whose sum is closest to zero, using sorting and two-pointer scanning.Medium5Two pointersSorting+1No attempts yet1s256 MBJudgeable
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.Medium5GreedyTwo pointers+2No attempts yet1s128 MBJudgeable
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.Medium5Dynamic programmingTwo pointers+2No attempts yet1s128 MBJudgeable
Sequence WalkingGiven two ascending integer sequences, find the maximum sum of a forward walk that may switch sequences at shared values.Medium5Dynamic programmingTwo pointersNo attempts yet1s128 MBJudgeable