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
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| FiguresCheck whether any three consecutive figures contain one circle, one square, and one triangle. | Easy1 | Sliding windowArray | No attempts yet | 1s | 128 MB | Judgeable |
| Weather Intern's Temperature SumGiven N daily temperatures, find the maximum sum over any contiguous window of exactly K days. | Easy2 | Sliding windowArray | No attempts yet | 1s | 128 MB | Judgeable |
| KaraokeCount the starting positions where the next K characters of the song string are all vowels. | Easy2 | Sliding windowString | No attempts yet | 2s | 128 MB | Judgeable |
| Minimum String DifferenceSlide the shorter string A across every possible alignment position over B and output the minimum number of mismatched characters. | Easy3 | StringSliding window+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Temperature SequenceFind the maximum sum of any K consecutive elements in an array of N temperatures. | Easy3 | Sliding windowPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Easy3 | Sliding windowArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| MusicCount length-m windows whose max minus min is at most c, across several small arrays. | Easy3 | Sliding windowArray | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum SumGiven n integers and a window size k, find the largest sum of any k consecutive terms. | Easy3 | ArraySliding window+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Easy3 | Sliding windowArray+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| Consecutive GirlsFind the fewest boys to remove so that k girls stand side by side in a row of n boys and girls. | Easy3 | Sliding windowPrefix sum+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 |
| Jumble MatchCount how many given words contain a substring that is a rearrangement of the pattern, where underscores match any letter. | Easy3 | Sliding windowString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| A Password Policy RequirementFind the shortest contiguous substring of at least six characters that contains an uppercase letter, a lowercase letter, and a digit. | Easy3 | Sliding windowString | 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 |
| 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. | Easy3 | Sliding windowArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Server Capacity PlanGiven sorted request times, find the smallest server count so no server exceeds k concurrent 1000ms jobs. | Easy3 | Sliding windowIntervals | No attempts yet | 1s | 256 MB | Judgeable |
| Diamond Collector (Bronze)Choose the largest group of diamonds whose sizes differ by at most K. | Easy3 | SortingSliding window | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Easy3 | Sliding windowPrefix sum+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Thief of the Circular VillageCount the starting positions of a circular window of M houses whose total amount stays below K. | Easy3 | Sliding windowPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Easy3 | Sliding windowArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cyclic ShiftsGiven a text T and a string S, decide whether T contains any cyclic shift of S as a contiguous substring. | Easy3 | StringString matching+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 |
| Glyph DecodingCount how many length-g substrings of S are letter-for-letter rearrangements of a given word W. | Medium4 | Sliding windowString+1 | No attempts yet | 2s | 128 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 |
| Collecting JewelsGiven N values in a line, find the maximum sum of a single contiguous run of length at least M taken once. | Medium4 | Prefix sumDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium4 | Sliding windowQueue+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium4 | ArraySliding window+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Good FriendsCount pairs of students within rank distance K whose names have equal length, given names in rank order. | Medium4 | Sliding windowArray+1 | No attempts yet | 1s | 128 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 |
| Moo SickFind every window of C consecutive notes whose sorted, min-subtracted shape matches the given chord's shape. | Medium4 | ArraySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium4 | Sliding windowArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Overshadowed TreesFor each tree, check whether any taller tree within K positions exceeds its height by at least M, and list all such trees. | Medium4 | Sliding windowArray+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| 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. | Medium4 | Sliding windowPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium4 | Prefix sumMatrix+1 | No attempts yet | 3s | 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 |
| Colorful ChainCount the contiguous segments that hold exactly the required number of links of each listed color and no other colors. | Medium4 | Sliding windowHash map+1 | No attempts yet | 3s | 512 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 |
| Sliding Window MinimumPrint the minimum of each window of length L ending at every position of the array. | Medium4 | Sliding windowQueue | No attempts yet | 2.4s | 512 MB | Judgeable |
| 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. | Medium4 | Sliding windowQueue | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium4 | Sliding windowString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TelescopeCount the horizontal shifts of an m by l weight grid over an m by n path where the weighted sum exceeds W. | Medium4 | Sliding windowPrefix sum+2 | No attempts yet | 1s | 512 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 |
| 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. | Medium4 | Sliding windowPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Medium5 | Sliding windowQueue+1 | No attempts yet | 2s | 256 MB | Judgeable |
| 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. | Medium5 | Sliding windowString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium5 | Sliding windowHash map+1 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium5 | Sliding windowString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium5 | Dynamic programmingSliding window | No attempts yet | 1s | 128 MB | Judgeable |
| IOIOICount the occurrences of the alternating string P_N (N+1 I's and N O's) as a substring of S, counting overlaps. | Medium5 | StringSliding window+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Longest Common SubstringGiven two uppercase strings of length up to 4000, find the length of the longest substring that occurs contiguously in both. | Medium5 | Dynamic programmingString+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Crazy SearchCount how many distinct length-N substrings appear in a given text, where the text uses characters from an alphabet of size NC. | Medium5 | StringHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Broken KeyboardFor each test case, find the length of the longest substring of the sentence that contains at most m distinct characters. | Medium5 | Sliding windowString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Building BlocksFind the minimum number of add/remove block moves so that some k consecutive columns end up with equal height. | Medium5 | Sliding windowPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium5 | Sliding windowTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| RadiotelegraphGiven n integers and at most w changes to any values, find the longest run of equal numbers achievable. | Medium5 | Sliding windowHash map | No attempts yet | 1s | 128 MB | Judgeable |
| Neighborhood RivalryEach cell of the grid needs the maximum value inside the square of radius R centered on it. | Medium5 | Sliding windowMatrix+1 | No attempts yet | 2.5s | 128 MB | Judgeable |
| MCSCount every length-k substring of a DNA string by its letter composition and report the size of the largest group. | Medium5 | Sliding windowHash map | No attempts yet | 5s | 128 MB | Judgeable |
| Encrypted passwordDecide whether the original password's letters can be rearranged to match a contiguous block inside the encrypted password. | Medium5 | Sliding windowHash map+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Crowded CowsCount cows that have a cow at least twice as tall within distance D on both the left and the right. | Medium5 | Sliding windowSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium5 | Hash mapSliding window+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Trending TopicMaintain word counts over a rolling 7-day window and answer each top N query in frequency order with ties included. | Medium5 | Sliding windowHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium5 | Sliding windowQueue+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium5 | GreedySliding window | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium5 | Sliding windowQueue | No attempts yet | 2s | 256 MB | Judgeable |
| Happy NumbersFind the smallest start of K consecutive integers with exactly L numbers that are at most M or prime, or output -1. | Medium5 | Number theoryPrefix sum+1 | No attempts yet | 0.5s | 64 MB | Judgeable |
| Sum of submatrix maximaAdd up the maximum value inside every K by K submatrix of an N by N matrix generated from two arrays. | Medium5 | Sliding windowMatrix+1 | No attempts yet | 20s | 1024 MB | Judgeable |
| Birthday PresentsPick a subset of presents whose price range is below D, maximizing total satisfaction. | Medium5 | SortingSliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Intervals of Unique NumbersCount pairs (i, j) where the subarray from i to j has all distinct values, with N up to 100000. | Medium5 | Two pointersSliding window+2 | No attempts yet | 1s | 32 MB | Judgeable |
| 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. | Medium5 | Hash mapString+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Mário's LockersGiven the positions of L free lockers, find the minimum number of swaps to gather N of them into consecutive positions. | Medium5 | Sliding windowPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Medium5 | GreedySliding window | No attempts yet | 5s | 512 MB | Judgeable |
| 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. | Medium5 | Two pointersSliding window+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium5 | Sliding windowArray+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| 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. | Medium5 | Sliding windowTwo pointers+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Medium5 | StackArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | Sliding windowMatrix+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | Sliding windowGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Sliding windowImplementation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | Prefix sumSliding window+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Sliding windowArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | StringTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Sliding windowTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FlowerpotFind the minimum width interval on the x axis that captures raindrops whose heights differ by at least D. | Medium6 | Two pointersSliding window+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow LineupFind the minimum span of x coordinates covering at least one cow of every distinct breed id. | Medium6 | SortingSliding window+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingSliding window+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DragonPick two disjoint blocks of at most K consecutive heads each in a row of N heads to maximize the total fire power removed. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| CitystarFor each street, find the five house numbers whose span (max minus min plus 1) is smallest, breaking ties by the smallest house numbers. | Medium6 | SortingSliding window+2 | No attempts yet | 1s | 128 MB | Judgeable |
| InversionsCount permutations of size n that have exactly k inversions, modulo 30011, using the Mahonian number recurrence with a sliding window over prefix sums. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RaceFind the length-m segment of the road that minimizes total riding time under piecewise constant speed limits. | Medium6 | Sliding windowPrefix sum+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Mine ClearingFind the most mines covered by one axis-aligned 10 by 10 square placed anywhere on the site. | Medium6 | Sliding windowSorting+1 | No attempts yet | 10s | 512 MB | Judgeable |
| 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. | Medium6 | Game theoryDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Measuring the MedianCompute the sum of the medians of every contiguous window of length K over N temperature readings. | Medium6 | HeapSliding window | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingSliding window | No attempts yet | 1s | 128 MB | Judgeable |
| Printing PlateFind the shortest plate that, pressed at every aligned position, leaves each fixed stripe in its own pure color. | Medium6 | Binary searchSliding window+1 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingSliding window | No attempts yet | 1s | 256 MB | Judgeable |
| Can't Stop (Small)Find the longest consecutive run of roll sets where every set contains at least one of k chosen numbers. | Medium6 | Sliding windowBacktracking | No attempts yet | 5s | 512 MB | Judgeable |