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 results180 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
FiguresCheck whether any three consecutive figures contain one circle, one square, and one triangle.Easy1Sliding windowArrayNo attempts yet1s128 MBJudgeable
Weather Intern's Temperature SumGiven N daily temperatures, find the maximum sum over any contiguous window of exactly K days.Easy2Sliding windowArrayNo attempts yet1s128 MBJudgeable
KaraokeCount the starting positions where the next K characters of the song string are all vowels.Easy2Sliding windowStringNo attempts yet2s128 MBJudgeable
Minimum String DifferenceSlide the shorter string A across every possible alignment position over B and output the minimum number of mismatched characters.Easy3StringSliding window+1No attempts yet2s128 MBJudgeable
Temperature SequenceFind the maximum sum of any K consecutive elements in an array of N temperatures.Easy3Sliding windowPrefix sum+1No attempts yet1s128 MBJudgeable
AlarmistGiven n samples and a window size w, compute the floor of each window average and report the difference between the largest and smallest average.Easy3Sliding windowArray+1No attempts yet1s128 MBJudgeable
MusicCount length-m windows whose max minus min is at most c, across several small arrays.Easy3Sliding windowArrayNo attempts yet1s128 MBJudgeable
Maximum SumGiven n integers and a window size k, find the largest sum of any k consecutive terms.Easy3ArraySliding window+1No attempts yet1s128 MBJudgeable
FishingFind the starting day among the first N days whose window of k consecutive days contains the most rainy days, choosing the smallest index on a tie.Easy3Sliding windowArray+1No attempts yet1s1024 MBJudgeable
Consecutive GirlsFind the fewest boys to remove so that k girls stand side by side in a row of n boys and girls.Easy3Sliding windowPrefix sum+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
Jumble MatchCount how many given words contain a substring that is a rearrangement of the pattern, where underscores match any letter.Easy3Sliding windowString+1No attempts yet1s128 MBJudgeable
A Password Policy RequirementFind the shortest contiguous substring of at least six characters that contains an uppercase letter, a lowercase letter, and a digit.Easy3Sliding windowStringNo 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
Rolling EncryptionEncrypt a lowercase string by leaving the first k letters unchanged and shifting each later letter by the most frequent of the k original letters before it.Easy3Sliding windowArray+1No attempts yet1s256 MBJudgeable
Server Capacity PlanGiven sorted request times, find the smallest server count so no server exceeds k concurrent 1000ms jobs.Easy3Sliding windowIntervalsNo attempts yet1s256 MBJudgeable
Diamond Collector (Bronze)Choose the largest group of diamonds whose sizes differ by at most K.Easy3SortingSliding windowNo attempts yet2s512 MBJudgeable
Sweet part-time jobJunsu can work at most m consecutive days out of n days with given daily wages; find the maximum total pay for such a window.Easy3Sliding windowPrefix sum+1No attempts yet1s512 MBJudgeable
Thief of the Circular VillageCount the starting positions of a circular window of M houses whose total amount stays below K.Easy3Sliding windowPrefix sum+2No attempts yet1s256 MBJudgeable
Why Did the Cow Cross the Road 5Given N traffic lights with B known broken positions, find the minimum number of broken lights to repair so that some K consecutive lights all work.Easy3Sliding windowArray+2No attempts yet2s512 MBJudgeable
Cyclic ShiftsGiven a text T and a string S, decide whether T contains any cyclic shift of S as a contiguous substring.Easy3StringString matching+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
Glyph DecodingCount how many length-g substrings of S are letter-for-letter rearrangements of a given word W.Medium4Sliding windowString+1No attempts yet2s128 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
Collecting JewelsGiven N values in a line, find the maximum sum of a single contiguous run of length at least M taken once.Medium4Prefix sumDynamic programming+1No attempts yet2s128 MBJudgeable
Finding Silent IntervalsFind every starting index of a length-m window in an array where the max minus min value is at most c, using a sliding window with monotonic deques.Medium4Sliding windowQueue+1No attempts yet1s128 MBJudgeable
Graphics QuizFor each of 5 grades, find the longest contiguous run of desks where at least one student has that grade, then output the best length and the smallest grade achieving it.Medium4ArraySliding window+1No attempts yet1s128 MBJudgeable
Good FriendsCount pairs of students within rank distance K whose names have equal length, given names in rank order.Medium4Sliding windowArray+1No attempts yet1s128 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
Moo SickFind every window of C consecutive notes whose sorted, min-subtracted shape matches the given chord's shape.Medium4ArraySorting+2No attempts yet1s128 MBJudgeable
Bridge TransportGiven car weights and a bridge that holds at most 4 cars, find the largest prefix that can cross without any window of 4 consecutive cars exceeding the weight limit.Medium4Sliding windowArray+2No attempts yet1s128 MBJudgeable
Bridge CrossingSplit a line of people into consecutive groups of at most M, where each group costs its slowest member's time, and minimize the total cost.Medium4Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Overshadowed TreesFor each tree, check whether any taller tree within K positions exceeds its height by at least M, and list all such trees.Medium4Sliding windowArray+2No attempts yet1s1024 MBJudgeable
Buffer ManagerGiven buffer states (free, digit worthiness, or locked) in a string, find the starting position of the K-length window without locked buffers whose digit sum is smallest.Medium4Sliding windowPrefix sum+2No attempts yet1s128 MBJudgeable
Density MapFor each cell of an n by n binary grid, sum the entries within Chebyshev distance r, using a 2D sliding-window or prefix-sum over the square neighborhood.Medium4Prefix sumMatrix+1No attempts yet3s128 MBJudgeable
PilotsFind the length of the longest contiguous fragment whose maximum minus minimum is at most t.Medium4Sliding windowTwo pointers+1No attempts yet3s128 MBJudgeable
Colorful ChainCount the contiguous segments that hold exactly the required number of links of each listed color and no other colors.Medium4Sliding windowHash map+1No attempts yet3s512 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
Sliding Window MinimumPrint the minimum of each window of length L ending at every position of the array.Medium4Sliding windowQueueNo attempts yet2.4s512 MBJudgeable
Miraculous DrugEach hour uses the cheapest enzyme bought within the last h hours, breaking ties toward the latest hour, and reports purchase counts over a given interval.Medium4Sliding windowQueueNo attempts yet1s256 MBJudgeable
DNA PasswordCount the length-|P| substrings of a DNA string that contain at least the required number of each of A, C, G, and T.Medium4Sliding windowString+2No attempts yet2s512 MBJudgeable
TelescopeCount the horizontal shifts of an m by l weight grid over an m by n path where the weighted sum exceeds W.Medium4Sliding windowPrefix sum+2No attempts yet1s512 MBJudgeable
KittyFind the longest contiguous substring with at most N distinct lowercase letters.Medium4Sliding windowTwo pointers+1No attempts yet1s512 MBJudgeable
Tired TerryGiven a circular sleep pattern of length n, count for how many seconds i the preceding p seconds contain fewer than d seconds of sleep.Medium4Sliding windowPrefix sum+2No attempts yet1s512 MBJudgeable
Run, HongjunGiven N billboard intensities and a sight range M, output the maximum intensity within a sliding window of size 2M-1 for each valid position.Medium5Sliding windowQueue+1No attempts yet2s256 MBJudgeable
String ExchangeGiven a circular string of a's and b's, find the minimum number of swaps to make all a's form one consecutive block.Medium5Sliding windowString+2No attempts yet2s128 MBJudgeable
Rotating SushiFind the maximum distinct sushi types among any k consecutive plates on a circular belt, adding one bonus for a given coupon type if not already present.Medium5Sliding windowHash map+1No attempts yet1s256 MBJudgeable
Chat RoomsFor each submitted line, decide accept or reject using consonant-run length, the count of recent suspicious lines, and recent duplicate counts over a sliding window of the last 10 lines.Medium5Sliding windowString+2No attempts yet1s128 MBJudgeable
RIPOFFA token moves 1 to S squares per turn and must exit a board of N labeled squares within T turns; maximize the total of the squares landed on.Medium5Dynamic programmingSliding windowNo attempts yet1s128 MBJudgeable
IOIOICount the occurrences of the alternating string P_N (N+1 I's and N O's) as a substring of S, counting overlaps.Medium5StringSliding window+2No attempts yet1s256 MBJudgeable
Longest Common SubstringGiven two uppercase strings of length up to 4000, find the length of the longest substring that occurs contiguously in both.Medium5Dynamic programmingString+2No attempts yet2s256 MBJudgeable
Crazy SearchCount how many distinct length-N substrings appear in a given text, where the text uses characters from an alphabet of size NC.Medium5StringHash map+2No attempts yet1s128 MBJudgeable
Broken KeyboardFor each test case, find the length of the longest substring of the sentence that contains at most m distinct characters.Medium5Sliding windowString+2No attempts yet1s128 MBJudgeable
Building BlocksFind the minimum number of add/remove block moves so that some k consecutive columns end up with equal height.Medium5Sliding windowPrefix sum+2No attempts yet1s128 MBJudgeable
Viewing TerracesIn a chain of terraces where climbing up costs height difference and descending is free, find the most distinct terraces reachable on k credits without returning to ground.Medium5Sliding windowTwo pointers+1No attempts yet1s128 MBJudgeable
RadiotelegraphGiven n integers and at most w changes to any values, find the longest run of equal numbers achievable.Medium5Sliding windowHash mapNo attempts yet1s128 MBJudgeable
Neighborhood RivalryEach cell of the grid needs the maximum value inside the square of radius R centered on it.Medium5Sliding windowMatrix+1No attempts yet2.5s128 MBJudgeable
MCSCount every length-k substring of a DNA string by its letter composition and report the size of the largest group.Medium5Sliding windowHash mapNo attempts yet5s128 MBJudgeable
Encrypted passwordDecide whether the original password's letters can be rearranged to match a contiguous block inside the encrypted password.Medium5Sliding windowHash map+1No attempts yet2s128 MBJudgeable
Crowded CowsCount cows that have a cow at least twice as tall within distance D on both the left and the right.Medium5Sliding windowSorting+1No attempts yet1s128 MBJudgeable
Joe is learning to speakTrack every word block up to length n from known sentences and ask about each unknown word and each new sentence with an unseen block.Medium5Hash mapSliding window+1No attempts yet3s128 MBJudgeable
Trending TopicMaintain word counts over a rolling 7-day window and answer each top N query in frequency order with ties included.Medium5Sliding windowHash map+1No attempts yet1s128 MBJudgeable
2D Max FilterFor every cell of an R by C grid, output the maximum value inside the rectangular window centered on that cell, clipped at the borders.Medium5Sliding windowQueue+1No attempts yet1s128 MBJudgeable
Condition of deep sleepTurn all N bulbs off with flips of exactly K consecutive bulbs using the fewest presses, or report Insomnia when it is impossible.Medium5GreedySliding windowNo attempts yet1s256 MBJudgeable
Hyper-minimumCompute the minimum of every M by M by M by M subcube of a 4D array with up to 1.5 million entries.Medium5Sliding windowQueueNo attempts yet2s256 MBJudgeable
Happy NumbersFind the smallest start of K consecutive integers with exactly L numbers that are at most M or prime, or output -1.Medium5Number theoryPrefix sum+1No attempts yet0.5s64 MBJudgeable
Sum of submatrix maximaAdd up the maximum value inside every K by K submatrix of an N by N matrix generated from two arrays.Medium5Sliding windowMatrix+1No attempts yet20s1024 MBJudgeable
Birthday PresentsPick a subset of presents whose price range is below D, maximizing total satisfaction.Medium5SortingSliding window+2No attempts yet2s512 MBJudgeable
Intervals of Unique NumbersCount pairs (i, j) where the subarray from i to j has all distinct values, with N up to 100000.Medium5Two pointersSliding window+2No attempts yet1s32 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
Mário's LockersGiven the positions of L free lockers, find the minimum number of swaps to gather N of them into consecutive positions.Medium5Sliding windowPrefix sum+2No attempts yet1s512 MBJudgeable
Oversized Pancake Flipper (Large)Given a row of happy or blank pancakes and a flipper of fixed width K, find the minimum number of flips that makes every pancake happy, or report that it is impossible.Medium5GreedySliding windowNo attempts yet5s512 MBJudgeable
Cute RyanGiven a row of N dolls labeled 1 or 2, find the length of the shortest contiguous block containing at least K dolls labeled 1.Medium5Two pointersSliding window+2No attempts yet1s256 MBJudgeable
Martian DNAGiven a string over K symbols and minimum counts for R of them, find the length of the shortest contiguous substring meeting all the quotas, or report impossible.Medium5Sliding windowArray+2No attempts yet2s1024 MBJudgeable
Rotating SushiOn a circular belt of N sushi plates, find the maximum number of distinct kinds in any k consecutive plates, counting the coupon kind c once more if it is not already present.Medium5Sliding windowTwo pointers+2No attempts yet1s512 MBJudgeable
Gahui's Remainder Sequence Game (Small)Maintain a sequence under push and pop from the back, and for each type-3 query report the shortest suffix whose values cover every residue 0 to mod-1, or -1 if impossible.Medium5StackArray+1No attempts yet1s256 MBJudgeable
Turning Off the LightsGiven a row of L bulbs and a fixed T-slot switch device that can be pressed at any aligned position any number of times, find the minimum number of bulbs left on.Medium6Dynamic programmingBit manipulation+2No attempts yet2s128 MBJudgeable
Submatrix Range QueriesGiven an N x N matrix and K fixed-size BxB submatrix queries, output the max minus min value for each queried window efficiently.Medium6Sliding windowMatrix+1No attempts yet2s128 MBJudgeable
Arranging ShapesGiven a sequence of three shape types, compute the minimum swaps needed to group each type into one contiguous block, in any order of blocks.Medium6Sliding windowGreedy+1No attempts yet1s128 MBJudgeable
RabbitsGiven a range update per day using sqrt-decomposition blocks with per-block cup counters and per-rabbit matchbox counters, report the sum of newly incremented counters each day.Medium6Sliding windowImplementation+2No attempts yet2s128 MBJudgeable
Camouflaged CampUsing prefix sums over the grid, find the L x W camp position that satisfies the most given adjacent-area altitude comparison rules, breaking ties by smallest row then column.Medium6Prefix sumSliding window+1No attempts yet1s128 MBJudgeable
ShuffleGiven a song-play log and playlist size s, count starting offsets that split the log into blocks of length s (first/last possibly shorter) with no repeated song inside any block.Medium6Sliding windowArray+1No attempts yet1s128 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
Cow LineupGiven a sequence of N breed IDs, remove at most K distinct breed IDs so that the longest run of equal IDs in the remaining sequence is maximized.Medium6Sliding windowTwo pointers+2No attempts yet1s128 MBJudgeable
FlowerpotFind the minimum width interval on the x axis that captures raindrops whose heights differ by at least D.Medium6Two pointersSliding window+1No attempts yet1s128 MBJudgeable
Cow LineupFind the minimum span of x coordinates covering at least one cow of every distinct breed id.Medium6SortingSliding window+2No attempts yet1s128 MBJudgeable
Mowing the LawnGiven N cows in a row with efficiencies, pick a subset that never includes more than K adjacent cows and maximize the total efficiency.Medium6Dynamic programmingSliding window+2No attempts yet1s128 MBJudgeable
Dividing the PathPartition the segment [0, L] into consecutive pieces of even length between 2A and 2B so no cut lands strictly inside any cow's interval, and minimize the number of pieces, or report that no partition exists.Medium6Dynamic programmingPrefix sum+2No attempts yet1s128 MBJudgeable
DragonPick two disjoint blocks of at most K consecutive heads each in a row of N heads to maximize the total fire power removed.Medium6Dynamic programmingPrefix sum+2No attempts yet1s1024 MBJudgeable
CitystarFor each street, find the five house numbers whose span (max minus min plus 1) is smallest, breaking ties by the smallest house numbers.Medium6SortingSliding window+2No attempts yet1s128 MBJudgeable
InversionsCount permutations of size n that have exactly k inversions, modulo 30011, using the Mahonian number recurrence with a sliding window over prefix sums.Medium6Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
RaceFind the length-m segment of the road that minimizes total riding time under piecewise constant speed limits.Medium6Sliding windowPrefix sum+1No attempts yet1s512 MBJudgeable
Mine ClearingFind the most mines covered by one axis-aligned 10 by 10 square placed anywhere on the site.Medium6Sliding windowSorting+1No attempts yet10s512 MBJudgeable
GameTwo players alternately add to S within a range set by the current parity, and whoever first reaches F loses, so decide if the first player can force a win.Medium6Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Measuring the MedianCompute the sum of the medians of every contiguous window of length K over N temperature readings.Medium6HeapSliding windowNo attempts yet1s256 MBJudgeable
Joy of the Cylinder GameChoose one cell in every row of the cylindrical grid within the step limit so the total is largest, and print the smallest best path.Medium6Dynamic programmingSliding windowNo attempts yet1s128 MBJudgeable
Printing PlateFind the shortest plate that, pressed at every aligned position, leaves each fixed stripe in its own pure color.Medium6Binary searchSliding window+1No attempts yet1s256 MBJudgeable
Orange ShippingPartition the ordered oranges into consecutive boxes of at most M to minimize the sum of K plus size times the size spread in each box.Medium6Dynamic programmingSliding windowNo attempts yet1s256 MBJudgeable
Can't Stop (Small)Find the longest consecutive run of roll sets where every set contains at least one of k chosen numbers.Medium6Sliding windowBacktrackingNo attempts yet5s512 MBJudgeable