brain

tamnd's digital brain — notes, problems, research

42641 notes

LeetCode 1937 - Maximum Number of Points with Cost

The problem gives us an m x n matrix called points. We must choose exactly one cell from every row. The value of the chosen cell is added to our score. However, there is a movement penalty between consecutive rows.

leetcodemediumarraydynamic-programmingmatrix
LeetCode 2926 - Maximum Balanced Subsequence Sum

This problem asks us to find the maximum sum of a balanced subsequence from a given integer array nums. A subsequence is a selection of elements from the array in their original order, possibly skipping elements.

leetcodehardarraybinary-searchdynamic-programmingbinary-indexed-treesegment-tree
LeetCode 2162 - Minimum Cost to Set Cooking Time

This problem asks us to simulate the process of entering a cooking time into a microwave while minimizing the total finger movement and button pressing cost. The microwave accepts at most four digits.

leetcodemediummathenumeration
LeetCode 2878 - Get the Size of a DataFrame

The problem asks us to determine the size of a DataFrame named players. Specifically, it requires computing two values: the number of rows and the number of columns.

leetcodeeasy
CF 213C - Relay Race

We are given an n×n grid where each cell contains an integer, which can be positive or negative. Furik starts at the top-left corner (1,1) and moves only right or down, while Rubik starts at the bottom-right corner (n,n) and moves only left or up.

codeforcescompetitive-programmingdp
LeetCode 3138 - Minimum Length of Anagram Concatenation

The problem gives us a string s that was formed by concatenating several strings together, where every piece is an anagram of the same unknown string t. Our task is to determine the minimum possible length of t.

leetcodemediumhash-tablestringcounting
LeetCode 2174 - Remove All Ones With Row and Column Flips II

The problem gives us an m x n binary matrix where every cell contains either 0 or 1. Our goal is to remove all 1s using the minimum number of operations. An operation can only be performed on a cell (i, j) that currently contains a 1.

leetcodemediumarraybit-manipulationbreadth-first-searchmatrix
CF 169B - Replacing Digits

We are given a decimal number as a string and another string containing extra digits that we may use for replacements. Every digit from the second string can be used at most once. For each chosen digit, we may replace any single position in the original number.

codeforcescompetitive-programminggreedy
LeetCode 3130 - Find All Possible Stable Binary Arrays II

The problem gives us three integers: - zero, the exact number of 0s that must appear in the array - one, the exact number of 1s that must appear in the array - limit, the maximum allowed length of any consecutive block of identical values We must count how many binary arrays…

leetcodeharddynamic-programmingprefix-sum
LeetCode 2653 - Sliding Subarray Beauty

The problem asks us to compute the beauty of every contiguous subarray of size k within a given integer array nums. The beauty of a subarray is defined as the xth smallest negative number in that subarray. If a subarray contains fewer than x negative numbers, the beauty is 0.

leetcodemediumarrayhash-tablesliding-window
LeetCode 3334 - Find the Maximum Factor Score of Array

The problem asks us to compute the maximum factor score of an array of integers, where the factor score is defined as the product of the GCD (greatest common divisor) and LCM (least common multiple) of all elements in the array.

leetcodemediumarraymathnumber-theory
LeetCode 3144 - Minimum Substring Partition of Equal Character Frequency

In this problem, we are given a lowercase English string s, and we must split it into one or more contiguous substrings such that every substring is balanced. A substring is considered balanced when every distinct character inside it appears the same number of times.

leetcodemediumhash-tablestringdynamic-programmingcounting
LeetCode 2571 - Minimum Operations to Reduce an Integer to 0

The problem asks us to find the minimum number of operations required to reduce a given positive integer n to 0, where each operation consists of adding or subtracting a power of two from the current value of n. A power of two is defined as any number of the form where .

leetcodemediumdynamic-programminggreedybit-manipulation
LeetCode 3351 - Sum of Good Subsequences

This problem asks us to compute the sum of all good subsequences in a given integer array nums. A subsequence is any sequence derived from nums by deleting zero or more elements without changing the order of the remaining elements.

leetcodehardarrayhash-tabledynamic-programming
LeetCode 3366 - Minimum Array Sum

We are given an array nums and two different operations that can reduce the values of elements in the array. The first operation divides a number by 2 and rounds the result upward.

leetcodemediumarraydynamic-programming
LeetCode 2791 - Count Paths That Can Form a Palindrome in a Tree

I can do that, but the guide will be very long for a single chat response because your required format includes detailed prose, brute force and optimal approaches, proof sketch, Python and Go implementations, worked traces for every example, complexity analysis, comprehensive…

leetcodehardhash-tablebit-manipulationtreedepth-first-search
LeetCode 2873 - Maximum Value of an Ordered Triplet I

You are given an integer array nums and must choose three indices (i, j, k) such that: - i < j < k - The triplet value is (nums[i] - nums[j]) nums[k] Among all valid ordered triplets, we want the maximum possible value.

leetcodeeasyarray
LeetCode 3271 - Hash Divided String

The problem asks us to compute a hashed string from an input string s by dividing it into equal-length substrings and then mapping each substring to a single character using a simple hashing function.

leetcodemediumstringsimulation
LeetCode 3020 - Find the Maximum Number of Elements in Subset

The problem gives us an array of positive integers and asks us to choose the largest possible subset that can be rearranged into a very specific symmetric structure. The required structure looks like this: where is a power of two.

leetcodemediumarrayhash-tableenumeration
LeetCode 2936 - Number of Equal Numbers Blocks

The problem is asking us to count the number of maximal contiguous blocks of equal numbers in a very large array nums. A block is maximal if it contains all consecutive occurrences of the same number, and numbers are guaranteed to appear in consecutive segments, i.e.

leetcodemediumarraybinary-searchinteractive
LeetCode 1968 - Array With Elements Not Equal to Average of Neighbors

The problem asks us to rearrange a distinct integer array so that no element is equal to the average of its neighbors. The input is a zero-indexed array nums of length at least 3, and all elements are guaranteed to be distinct.

leetcodemediumarraygreedysorting
LeetCode 3024 - Type of Triangle

The problem gives an integer array nums of length 3, where each value represents the length of a side of a possible triangle. Our task is to determine what kind of triangle these three sides can form.

leetcodeeasyarraymathsorting
LeetCode 3318 - Find X-Sum of All K-Long Subarrays I

The problem asks us to compute a special value called the x-sum for every contiguous subarray of length k. For each window of size k, we first count how many times each number appears. After that, we only keep the contributions of the top x most frequent distinct values.

leetcodeeasyarrayhash-tablesliding-windowheap-(priority-queue)
LeetCode 2879 - Display the First Three Rows

The problem requires displaying the first three rows of a given DataFrame named employees. The DataFrame contains four columns: employeeid, name, department, and salary.

leetcodeeasy
LeetCode 2474 - Customers With Strictly Increasing Purchases

The problem gives us an Orders table where each row represents a purchase made by a customer. Every order has an orderid, a customerid, an orderdate, and a price.

leetcodeharddatabase
LeetCode 2085 - Count Common Words With One Occurrence

This problem gives us two arrays of strings, words1 and words2. Our task is to count how many strings appear exactly once in both arrays. The key detail is that a word only qualifies if: 1. It appears exactly one time in words1 2.

leetcodeeasyarrayhash-tablestringcounting
CF 173A - Rock-Paper-Scissors

In this problem, two players, Nikephoros and Polycarpus, play multiple rounds of rock-paper-scissors. Each player has a fixed sequence of moves that they cycle through as the rounds progress.

codeforcescompetitive-programmingimplementationmath
CF 255C - Almost Arithmetical Progression

We are given a sequence of integers and asked to find the longest subsequence that forms an almost arithmetical progression.

codeforcescompetitive-programmingbrute-forcedp
LeetCode 2358 - Maximum Number of Groups Entering a Competition

The problem asks us to partition a list of student grades into multiple ordered groups under two strict conditions. First, the total sum of grades in the i-th group must be less than that of the (i+1)-th group.

leetcodemediumarraymathbinary-searchgreedy
CF 177A1 - Good Matrix Elements

We are given a square matrix of size n × n, where n is guaranteed to be an odd number. Each element of the matrix is a non-negative integer.

codeforcescompetitive-programmingimplementation
LeetCode 2389 - Longest Subsequence With Limited Sum

This problem asks us to determine, for each query, the maximum number of elements we can select from an array nums such that their sum does not exceed a given value.

leetcodeeasyarraybinary-searchgreedysortingprefix-sum
CF 187B - AlgoRace

We have a complete directed graph on n cities. For every car type, we know the travel time between every ordered pair of cities. These travel times are not guaranteed to be symmetric, so going from u to v may cost something different than going from v to u.

codeforcescompetitive-programmingdpshortest-paths
LeetCode 3311 - Construct 2D Grid Matching Graph Layout

The problem gives us an undirected graph with n nodes labeled from 0 to n - 1. We must place every node into a 2D grid so that adjacency in the grid matches adjacency in the graph exactly.

leetcodehardarrayhash-tablegraph-theorymatrix
LeetCode 2988 - Manager of the Largest Department

You included two different problems in one message, and the second prompt overrides the first at the end. I will answer for LeetCode 2988 - Manager of the Largest Department.

leetcodemediumdatabase
LeetCode 2624 - Snail Traversal

The problem asks us to take a 1D array of integers and convert it into a 2D matrix of specified dimensions, rowsCount and colsCount, following a snail traversal order by columns.

leetcodemedium
CF 158D - Ice Sculptures

We have n ice sculptures placed evenly on a circle. Each sculpture has a value, which may be positive or negative. We may remove some sculptures, but the remaining ones must still form a regular polygon.

codeforcescompetitive-programming*specialbrute-forcenumber-theory
CF 248A - Cupboards

We are given a set of cupboards, each with two doors: left and right. Each door can be either open or closed. The initial state of each door is given in the input. Karlsson wants all left doors to be in the same position and all right doors to be in the same position.

codeforcescompetitive-programmingimplementation
LeetCode 2259 - Remove Digit From Number to Maximize Result

The problem gives us a string called number, which represents a positive integer, and a character digit, which is guaranteed to appear at least once inside number.

leetcodeeasystringgreedyenumeration
LeetCode 2606 - Find the Substring With Maximum Cost

The problem asks us to find the substring of a given string s that maximizes a custom cost function. Each character in the string has a value: if it exists in the string chars, its value is taken from the corresponding index in the array vals; if it does not exist in chars…

leetcodemediumarrayhash-tablestringdynamic-programming
LeetCode 3186 - Maximum Total Damage With Spell Casting

The problem gives us an array power, where each element represents the damage value of a spell. Every spell can be used at most once, and multiple spells may share the same damage value. The restriction is the important part of the problem.

leetcodemediumarrayhash-tabletwo-pointersbinary-searchdynamic-programmingsortingcounting
LeetCode 2869 - Minimum Operations to Collect Elements

This problem gives us an array nums and an integer k. We repeatedly perform an operation where we remove the last element of the array and add it to our collection.

leetcodeeasyarrayhash-tablebit-manipulation
CF 149A - Business trip

Petya can decide in which months he waters the flower. Each month contributes a fixed amount of growth, and skipping a month contributes nothing. The goal is to reach at least k centimeters of total growth while using as few months as possible.

codeforcescompetitive-programminggreedyimplementationsortings
LeetCode 2099 - Find Subsequence of Length K With the Largest Sum

The problem asks us to find a subsequence of length k from a given integer array nums such that the sum of the elements in the subsequence is maximized.

leetcodeeasyarrayhash-tablesortingheap-(priority-queue)
CF 140B - New Year Cards

Alexander receives cards from friends one by one. Friend i sends card i, so card numbers and friend numbers are the same thing. At any moment Alexander may decide to send cards to some friends. He never creates new cards, he only reuses cards he has already received.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
LeetCode 1864 - Minimum Number of Swaps to Make the Binary String Alternating

The problem gives us a binary string s that contains only '0' and '1'. We are allowed to swap any two characters in the string, not necessarily adjacent ones. Our goal is to transform the string into an alternating binary string using the minimum number of swaps.

leetcodemediumstringgreedy
LeetCode 2755 - Deep Merge of Two Objects

Here is the complete technical solution guide for LeetCode 2755 following your requested format. The problem asks us to deep merge two JSON values, obj1 and obj2. The merging rules depend on the type of the values at each position in the objects or arrays.

leetcodemedium
LeetCode 3299 - Sum of Consecutive Subsequences

We are given an array nums, and we must consider all non-empty subsequences of that array. A subsequence preserves the original order of elements, but elements do not need to be contiguous.

leetcodehardarrayhash-tabledynamic-programming
LeetCode 2774 - Array Upper Bound

The problem asks us to enhance JavaScript arrays with a method called upperBound(). Given a sorted array of numbers and a target value, the method should return the last index where the target appears. If the target does not exist in the array, the method should return -1.

leetcodeeasy
LeetCode 2992 - Number of Self-Divisible Permutations

The problem asks us to count how many permutations of the numbers 1 through n satisfy a special condition called self-divisible. We start with the array: We must rearrange these numbers into every possible permutation, then determine whether the permutation is valid.

leetcodemediumarraymathdynamic-programmingbacktrackingbit-manipulationnumber-theorybitmask
CF 182E - Wooden Fence

We are asked to count the number of ways to build a fence of exact length l using boards of n types, where each type is a rectangle of dimensions ai by bi.

codeforcescompetitive-programmingdp
CF 249D - Donkey and Stars

We are asked to find the longest chain of stars the Donkey can select under a geometric rule. The stars are points on a plane, and we begin at the origin. From any star, we imagine two rays at fixed angles relative to the horizontal axis.

codeforcescompetitive-programmingdata-structuresdpgeometrymathsortings
LeetCode 3152 - Special Array II

We are given an integer array nums and several queries. Each query specifies a subarray using two indices [fromi, toi]. For every query, we must determine whether the subarray nums[fromi..toi] is a special array.

leetcodemediumarraybinary-searchprefix-sum
LeetCode 3048 - Earliest Second to Mark Indices I

We are given two 1-indexed arrays: - nums, where nums[i] represents how many decrement operations index i still needs before it becomes zero. - changeIndices, where changeIndices[s] tells us which index is eligible to be marked at second s. Initially, every index is unmarked.

leetcodemediumarraybinary-search
LeetCode 2506 - Count Pairs Of Similar Strings

The problem gives us an array of strings called words. We must count how many pairs of indices (i, j) satisfy two conditions: - i < j - words[i] and words[j] are similar Two strings are considered similar if they contain exactly the same set of distinct characters, regardless…

leetcodeeasyarrayhash-tablestringbit-manipulationcounting
LeetCode 2113 - Elements in Array After Removing and Replacing Elements

The problem describes an array that continuously goes through a repeating two-phase process. At minute 0, the array is unchanged. Every following minute, the leftmost element is removed until the array becomes empty.

leetcodemediumarray
CF 161A - Dress'em in Vests!

We are tasked with equipping as many soldiers as possible with bulletproof vests. Each soldier has a preferred vest size, but they are willing to tolerate deviations within a given range. Specifically, the i-th soldier can wear any vest with a size between a[i] - x and a[i] + y.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedytwo-pointers
LeetCode 2410 - Maximum Matching of Players With Trainers

This problem requires us to maximize the number of matchings between players and trainers under the condition that a player's ability cannot exceed the trainer's training capacity. In other words, a player i can only be assigned to trainer j if players[i] <= trainers[j].

leetcodemediumarraytwo-pointersgreedysorting
LeetCode 2600 - K Items With the Maximum Sum

The problem asks us to determine the maximum possible sum when picking exactly k items from a bag containing items labeled 1, 0, or -1.

leetcodeeasymathgreedy
CF 448A - Rewards

We are given a fixed number of shelves and a collection of rewards split into two categories, cups and medals. Each category is further divided into three ranks, but for the placement logic those ranks do not matter beyond counting total items in each category.

codeforcescompetitive-programmingimplementation
CF 138B - Digits Permutations

We are given a decimal number as a string. We may independently permute its digits twice, producing two new numbers that contain exactly the same multiset of digits as the original number. Leading zeroes are allowed after permutation.

codeforcescompetitive-programminggreedy
LeetCode 1985 - Find the Kth Largest Integer in the Array

This problem asks us to find the kth largest value among a list of integers that are represented as strings. Each element in nums is a non-negative integer encoded as a string with no leading zeros, and we are required to return the kth largest value according to numeric order…

leetcodemediumarraystringdivide-and-conquersortingheap-(priority-queue)quickselect
CF 203B - Game on Paper

We have an n × n grid that starts completely white. Cells are painted black one by one, and every move paints a different cell. After each move, we want to know whether the board already contains a completely black 3 × 3 square.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 2806 - Account Balance After Rounded Purchase

The problem is asking us to simulate a simple bank account deduction after making a purchase. You start with an initial balance of 100 dollars. The purchase amount is given as an integer, purchaseAmount, representing the cost of an item in dollars.

leetcodeeasymath
LeetCode 2159 - Order Two Columns Independently

The problem provides a database table named Data with two integer columns: firstcol and secondcol. Each row represents a pair of numbers, and duplicate rows are allowed.

leetcodemediumdatabase
LeetCode 3219 - Minimum Cost for Cutting Cake II

We are given an m x n rectangular cake and need to divide it completely into 1 x 1 pieces. The cake can be cut along predefined horizontal and vertical lines.

leetcodehardarraygreedysorting
CF 233A - Perfect Permutation

We need to construct a permutation of numbers from 1 to n with two conditions. The first condition is p[p[i]] = i for every position i. Applying the permutation twice must return us to the original index. This means every element points back to its partner.

codeforcescompetitive-programmingimplementationmath
CF 161B - Discounts

We have a collection of items sold in a supermarket. Every item has a price and a type. Type 1 means the item is a stool, type 2 means it is a pencil. Polycarpus owns exactly k shopping carts, and every cart must contain at least one item.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortings
LeetCode 2499 - Minimum Total Cost to Make Arrays Unequal

You are given two arrays, nums1 and nums2, both of length n. You are allowed to perform operations only on nums1. In a single operation, you may swap any two indices in nums1, and the cost of that operation is the sum of the two indices involved in the swap.

leetcodehardarrayhash-tablegreedycounting
CF 254B - Jury Size

Each Olympiad happens on a fixed calendar date in 2013. Before that date, a group of jury members must work continuously for several days. If an Olympiad needs p people and t preparation days, then exactly p people are busy on each of the t days immediately before the Olympiad.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 2182 - Construct String With Repeat Limit

The problem asks us to construct a string from the characters of a given string s under a specific constraint: no character can appear more than repeatLimit times consecutively.

leetcodemediumhash-tablestringgreedyheap-(priority-queue)counting
LeetCode 3343 - Count Number of Balanced Permutations

We are given a string num consisting only of digits. We may rearrange the digits in any possible way, but we only count distinct permutations. A permutation is considered balanced if the sum of the digits placed at even indices equals the sum of the digits placed at odd indices.

leetcodehardmathstringdynamic-programmingcombinatorics
LeetCode 3336 - Find the Number of Subsequences With Equal GCD

The problem asks us to count the number of pairs of non-empty disjoint subsequences from a given array nums such that the GCD of the elements in each subsequence of the pair is equal.

leetcodehardarraymathdynamic-programmingnumber-theory
CF 213A - Game

We are given a game split into n parts. Each part must be completed on a specific computer, and some parts depend on others, forming a dependency graph without cycles. Rubik can start at any computer and spends exactly one hour to complete a part.

codeforcescompetitive-programmingdfs-and-similargreedy
LeetCode 2411 - Smallest Subarrays With Maximum Bitwise OR

The problem asks us to find, for each index in a given array nums, the length of the shortest contiguous subarray starting at that index whose bitwise OR is equal to the maximum possible bitwise OR obtainable from that index onward.

leetcodemediumarraybinary-searchbit-manipulationsliding-window
CF 140E - New Year Garland

The input array differences describes how consecutive values in an unknown array change from one position to the next.

codeforcescompetitive-programmingcombinatoricsdp
CF 429A - Xor-tree

We are given a rooted tree with n nodes, each node labeled with a 0 or 1. We are also given a target configuration of 0s and 1s for each node. The only operation allowed is to "pick" a node, which flips its value and every second-level descendant down the tree.

codeforcescompetitive-programmingdfs-and-similartrees
CF 202A - LLPS

We are given a lowercase string and must choose some characters, in order, to form a subsequence that is both a palindrome and lexicographically as large as possible. A subsequence does not need to stay contiguous.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcegreedyimplementationstrings
CF 167B - Wizards and Huge Prize

We are asked to calculate the probability of performing well in a sequence of wizard contests, given both your chances of winning each contest and the types of prizes you may receive.

codeforcescompetitive-programmingdpmathprobabilities
LeetCode 2170 - Minimum Operations to Make the Array Alternating

The problem requires transforming a given integer array nums into an alternating array with the minimum number of operations.

leetcodemediumarrayhash-tablegreedycounting
LeetCode 2920 - Maximum Points After Collecting Coins From All Nodes

We are given a tree with n nodes rooted at node 0. Each node contains a certain number of coins. We must collect coins from every node while respecting the tree hierarchy, meaning a node can only be processed after all of its ancestors have already been processed.

leetcodehardarraydynamic-programmingbit-manipulationtreedepth-first-searchmemoization
LeetCode 3324 - Find the Sequence of Strings Appeared on the Screen

The problem gives us a target string and a very restricted keyboard with only two operations. The first key always appends the character "a" to the end of the current string. The second key changes only the last character of the current string to the next letter in the alphabet.

leetcodemediumstringsimulation
CF 203D - Hit Ball

We are asked to simulate a three-dimensional billiard-like scenario where a ball travels inside a rectangular corridor with perfectly reflecting walls, floor, and ceiling.

codeforcescompetitive-programminggeometryimplementationmath
CF 251E - Tree and Table

We are given a tree with $2n$ nodes, and the goal is to place each node into a 2-row by $n$-column table so that each edge of the tree connects two cells sharing a side. Each node occupies exactly one cell, and each cell contains exactly one node.

codeforcescompetitive-programmingdfs-and-similardpimplementationtrees
LeetCode 2361 - Minimum Costs Using the Train Line

This problem models a scenario where you are traversing a train line with two parallel routes: a regular route and an express route. Each route has a series of consecutive stops, and the cost to move from one stop to the next is provided in the arrays regular and express.

leetcodehardarraydynamic-programming
LeetCode 2148 - Count Elements With Strictly Smaller and Greater Elements

The problem gives us an integer array nums and asks us to count how many elements satisfy a very specific condition.

leetcodeeasyarraysortingcounting
LeetCode 3096 - Minimum Levels to Gain More Points

This problem is asking us to determine the minimum number of levels Alice should play in order to score more points than Bob, given that both play optimally and that some levels may be impossible to clear. The input is a binary array possible of length n.

leetcodemediumarrayprefix-sum
LeetCode 2688 - Find Active Users

The problem gives us a database table named Users. Each row represents a purchase made by a user. The columns include: - userid, the identifier of the user - item, the purchased product - createdat, the purchase timestamp - amount, the purchase value The table may contain…

leetcodemediumdatabase
LeetCode 2583 - Kth Largest Sum in a Binary Tree

The problem gives us the root of a binary tree and an integer k. For every level in the tree, we calculate the sum of all node values that appear on that level. After computing all level sums, we must return the kth largest level sum.

leetcodemediumtreebreadth-first-searchsortingbinary-tree
LeetCode 2459 - Sort Array by Moving Items to Empty Space

The array contains every integer from 0 to n - 1 exactly once. The value 0 represents the empty space, while every other number represents an item that should eventually appear in sorted order. The operation is unusual compared to normal array sorting problems.

leetcodehardarrayhash-tablesorting
LeetCode 2080 - Range Frequency Queries

The problem asks us to design a data structure that can efficiently answer frequency queries on subarrays. We are given an integer array arr, and we need to support repeated queries of the form: - Given left, right, and value - Return how many times value appears in the…

leetcodemediumarrayhash-tablebinary-searchdesignsegment-tree
LeetCode 2435 - Paths in Matrix Whose Sum Is Divisible by K

This problem asks us to count the number of paths in a 2D integer matrix from the top-left corner (0, 0) to the bottom-right corner (m - 1, n - 1) such that the sum of the values along the path is divisible by a given integer k.

leetcodehardarraydynamic-programmingmatrix
CF 158A - Next Round

We are given the final standings of a programming contest. The scores are already sorted in non-increasing order, meaning each participant has a score greater than or equal to the next participant. A participant advances to the next round if two conditions are true.

codeforcescompetitive-programming*specialimplementation
CF 250A - Paper Work

Polycarpus needs to organize daily profit reports into folders, where each folder contains consecutive days. The key restriction is that a folder cannot contain three or more days with negative profit, because the boss cannot tolerate more than two loss days per folder.

codeforcescompetitive-programminggreedy
CF 187D - BRT Contract

A bus travels through a fixed sequence of road segments. Between consecutive segments there are traffic lights, and every light follows the same synchronized cycle. Each cycle lasts g + r seconds.

codeforcescompetitive-programmingdata-structures
CF 417D - Cunning Gena

Gena has a set of problems, and a group of friends who can each solve some subset of them. If Gena hires a friend, that friend will solve all problems they are capable of solving, covering multiple problems at once.

codeforcescompetitive-programmingbitmasksdpgreedysortings
CF 138D - World of Darkraft

We have a rectangular board where every cell contains one of three symbols. A move selects an active cell and disables cells along diagonals passing through it. The exact diagonals depend on the symbol. A cell marked L attacks the two diagonals with constant i + j.

codeforcescompetitive-programmingdpgames
LeetCode 2395 - Find Subarrays With Equal Sum

The problem asks us to determine whether there exist two contiguous subarrays of length 2 in a given array nums that have the same sum. A subarray of length 2 is simply any consecutive pair of elements in the array.

leetcodeeasyarrayhash-table
LeetCode 1853 - Convert Date Format

The problem provides a database table named Days with a single column called day. Each value in this column is a valid SQL DATE, and every value is unique.

leetcodeeasydatabase
LeetCode 2109 - Adding Spaces to a String

The problem requires us to insert spaces into a given string s at specific positions described by the array spaces. Each element in spaces represents an index in the string before which a space should be inserted.

leetcodemediumarraytwo-pointersstringsimulation
LeetCode 2829 - Determine the Minimum Sum of a k-avoiding Array

The problem asks us to construct an array of n distinct positive integers such that no two elements in the array sum to a given integer k. This type of array is called k-avoiding.

leetcodemediummathgreedy