brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 1918 - Kth Smallest Subarray Sum

The problem asks us to find the kth smallest sum among all possible non-empty contiguous subarrays of a given integer array nums. Each subarray is formed by taking a contiguous sequence of elements from nums, and its sum is the sum of the elements in that subarray.

leetcodemediumarraybinary-searchsliding-window
CF 417B - Crash

We are given a list of submissions made by participants in a programming contest. Each submission is described by two numbers: x, which counts how many unique solutions this participant had already submitted before this one, and k, the participant's ID.

codeforcescompetitive-programmingimplementation
LeetCode 2542 - Maximum Subsequence Score

The problem gives us two integer arrays, nums1 and nums2, both of the same length n, along with an integer k. We must choose exactly k indices from the arrays.

leetcodemediumarraygreedysortingheap-(priority-queue)
LeetCode 2138 - Divide a String Into Groups of Size k

The problem asks us to split a string into consecutive groups, where every group must contain exactly k characters. We process the string from left to right. The first k characters form the first group, the next k characters form the second group, and so on.

leetcodeeasystringsimulation
LeetCode 2967 - Minimum Cost to Make Array Equalindromic

We are given an integer array nums. We may repeatedly choose any element and replace it with any positive integer x. Replacing a value nums[i] with x costs |nums[i] - x|.

leetcodemediumarraymathbinary-searchgreedysorting
LeetCode 2993 - Friday Purchases I

The problem asks us to compute the total amount spent on Fridays in each week of November 2023. We are given a database table named Purchases, where each row represents a purchase made by a user on a specific date, along with the amount spent.

leetcodemediumdatabase
LeetCode 2901 - Longest Unequal Adjacent Groups Subsequence II

The problem asks us to select the longest subsequence of words from a given array such that adjacent words in the subsequence satisfy two conditions: first, their corresponding groups values are different, and second, the words are of the same length and differ by exactly one…

leetcodemediumarraystringdynamic-programming
CF 165D - Beard Graph

The graph in this problem is almost a simple path. Every vertex has degree at most 2, except possibly one special vertex that may have larger degree. A tree with this shape looks like several chains glued together at one center. Initially every edge is black.

codeforcescompetitive-programmingdata-structuresdsutrees
LeetCode 1923 - Longest Common Subpath

The problem asks us to find the maximum length of a contiguous sequence of cities that appears in every friend's travel path. Each friend has a path represented as an array of city IDs. A subpath is simply a contiguous segment of that array.

leetcodehardarraybinary-searchrolling-hashsuffix-arrayhash-function
LeetCode 2462 - Total Cost to Hire K Workers

The problem asks us to simulate a process of hiring k workers from a list costs, where each worker has an associated cost. We can hire workers only from the first candidates workers or the last candidates workers in each hiring session.

leetcodemediumarraytwo-pointersheap-(priority-queue)simulation
LeetCode 2682 - Find the Losers of the Circular Game

This problem describes a circular passing game among n friends numbered from 1 to n. The ball always starts with friend 1, and each turn increases the number of clockwise steps by a multiple of k.

leetcodeeasyarrayhash-tablesimulation
LeetCode 3197 - Find the Minimum Area to Cover All Ones II

The problem gives us a binary matrix grid, where each cell contains either 0 or 1. Our goal is to place exactly three non-overlapping axis-aligned rectangles so that every cell containing 1 is covered by at least one rectangle.

leetcodehardarraymatrixenumeration
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
LeetCode 2886 - Change Data Type

This problem provides a Pandas DataFrame named students with four columns: | Column | Type | | --- | --- | | studentid | int | | name | object | | age | int | | grade | float | The task is straightforward: the grade column is incorrectly stored as floating-point values, and we…

leetcodeeasy
CF 138E - Hellish Constraints

We are asked to count substrings of a given string that satisfy a complicated set of constraints. Each constraint specifies a letter and a minimum and maximum number of times that letter can appear.

codeforcescompetitive-programmingbrute-forcedptwo-pointers
LeetCode 2508 - Add Edges to Make Degrees of All Nodes Even

The problem gives us an undirected graph with n nodes and a list of edges. Each edge connects two different nodes, and the graph may contain multiple disconnected components.

leetcodehardhash-tablegraph-theory
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
LeetCode 2854 - Rolling Average Steps

This problem asks us to compute a 3-day rolling average of daily step counts for each user. The input is a table named Steps, where each row contains: - userid, identifying a user. - stepscount, the number of steps taken on a particular day.

leetcodemediumdatabase
LeetCode 3315 - Construct the Minimum Bitwise Array II

We are given an array nums where every element is a prime number. For each value nums[i], we must find the smallest non-negative integer ans[i] such that: where | denotes the bitwise OR operation. If no such value exists, we must place -1 in the answer array at that position.

leetcodemediumarraybit-manipulation
LeetCode 2560 - House Robber IV

The problem describes a scenario where a robber wants to steal from houses lined along a street, but with the constraint that adjacent houses cannot both be robbed.

leetcodemediumarraybinary-searchdynamic-programminggreedy
CF 406E - Hamming Triples

The problem presents a collection of binary strings of a fixed length, but rather than giving the strings explicitly, each string is described compactly: the first $fi$ bits are the same, $si$, and the remaining $n-fi$ bits are the opposite of $si$.

codeforcescompetitive-programmingimplementationmathtwo-pointers
LeetCode 1959 - Minimum Total Space Wasted With K Resizing Operations

Let's go through a full, detailed technical solution guide for LeetCode 1959 following your formatting and style rules. This problem asks us to minimize the total wasted space when resizing a dynamic array multiple times.

leetcodemediumarraydynamic-programmingprefix-sum
LeetCode 2807 - Insert Greatest Common Divisors in Linked List

This problem gives us the head of a singly linked list where every node contains a positive integer. Our task is to modify the list by inserting a new node between every pair of adjacent nodes.

leetcodemediumlinked-listmathnumber-theory
LeetCode 2845 - Count of Interesting Subarrays

The problem is asking us to count the number of interesting subarrays in a given array nums. An interesting subarray is defined by a modular counting condition: within any subarray nums[l..r], count the number of elements nums[i] where nums[i] % modulo == k.

leetcodemediumarrayhash-tableprefix-sum
LeetCode 2469 - Convert the Temperature

The problem gives us a single floating point value named celsius, representing a temperature measured in degrees Celsius. Our task is to convert this temperature into two other temperature scales, Kelvin and Fahrenheit, and return both converted values in an array.

leetcodeeasymath
CF 212B - Polycarpus is Looking for Good Substrings

We are given one long lowercase string s. For every query, we are also given a set of characters C. Among all substrings of s, we only care about those whose set of distinct characters is exactly C. From those substrings, we must count how many are maximal by inclusion.

codeforcescompetitive-programmingbitmaskshashingimplementation
LeetCode 2537 - Count the Number of Good Subarrays

LeetCode 2537: Count the Number of Good Subarrays (Medium)

leetcodemediumarrayhash-tablesliding-window
LeetCode 3040 - Maximum Number of Operations With the Same Score II

This problem asks us to determine the maximum number of operations that can be performed on an array of integers, where every operation removes two elements from specific positions (either the first two elements, the last two elements, or the first and last elements), and…

leetcodemediumarraydynamic-programmingmemoization
CF 431E - Chemistry Experiment

We are given a set of containers, each containing some fixed amount of mercury. Over time, two kinds of operations happen. The first operation changes the mercury amount in a single container.

codeforcescompetitive-programmingbinary-searchdata-structuresternary-search
CF 197A - Plate Game

We have a rectangular table with dimensions a × b and an unlimited supply of identical circular plates with radius r. Two players alternate placing plates on the table. Every plate must lie completely inside the rectangle, and plates may touch but cannot overlap.

codeforcescompetitive-programmingconstructive-algorithmsgamesmath
LeetCode 2201 - Count Artifacts That Can Be Extracted

This problem models an excavation process on a square n x n grid. Several rectangular artifacts are buried in the grid, and each artifact occupies one or more cells.

leetcodemediumarrayhash-tablesimulation
CF 161E - Polycarpus the Safecracker

We are given several prime numbers. Each prime represents the first row of a square matrix of digits. If the prime has length n, then the matrix is n × n. The matrix must satisfy two conditions. First, every row interpreted as a decimal number must itself be prime.

codeforcescompetitive-programmingbrute-forcedp
LeetCode 3016 - Minimum Number of Pushes to Type Word II

This problem asks us to redesign a telephone keypad so that typing a given word requires the fewest total key presses possible. A traditional telephone keypad contains keys 2 through 9, giving us exactly 8 available keys.

leetcodemediumhash-tablestringgreedysortingcounting
LeetCode 1983 - Widest Pair of Indices With Equal Range Sum

The problem asks us to find the widest subarray (continuous segment) in two binary arrays nums1 and nums2 such that the sum of elements in that segment is equal for both arrays. Formally, we need to find indices (i, j) with i <= j such that: and maximize the distance j - i + 1.

leetcodemediumarrayhash-tableprefix-sum
LeetCode 2191 - Sort the Jumbled Numbers

The problem asks us to sort an array of integers based on a custom digit mapping rather than their natural numeric value.

leetcodemediumarraysorting
LeetCode 2696 - Minimum String Length After Removing Substrings

The problem asks us to determine the minimum possible length of a string after repeatedly removing the substrings "AB" or "CD". We are given a string s consisting solely of uppercase English letters.

leetcodeeasystringstacksimulation
LeetCode 2257 - Count Unguarded Cells in the Grid

This problem gives us an m x n grid containing three types of cells: 1. Guard cells 2. Wall cells 3. Empty cells Each guard can observe cells in the four cardinal directions: - Up - Down - Left - Right A guard continues seeing cells in a direction until the view is blocked by…

leetcodemediumarraymatrixsimulation
LeetCode 1967 - Number of Strings That Appear as Substrings in Word

The problem asks us to determine how many strings in the array patterns appear as substrings within a given string word. A substring is defined as a contiguous sequence of characters, meaning the characters must appear in order and without gaps inside word.

leetcodeeasyarraystring
LeetCode 1904 - The Number of Full Rounds You Have Played

The problem describes an online chess tournament where a new round begins every 15 minutes. A player can only be credited for a full round if they are present for the entire duration of that round.

leetcodemediummathstring
LeetCode 2996 - Smallest Missing Integer Greater Than Sequential Prefix Sum

The problem asks us to find the smallest missing integer in the array that is greater than or equal to the sum of the longest sequential prefix. A sequential prefix means the beginning part of the array where every number increases by exactly 1 compared to the previous number.

leetcodeeasyarrayhash-tablesorting
LeetCode 2667 - Create Hello World Function

The problem asks us to implement a function named createHelloWorld that returns another function. The returned function must always produce the string "Hello World" whenever it is called.

leetcodeeasy
LeetCode 2084 - Drop Type 1 Orders for Customers With Type 0 Orders

In this problem, we are given a database table named Orders. Each row represents a single order and contains three columns: - orderid, the unique identifier for the order - customerid, the customer who placed the order - ordertype, which is either 0 or 1 The task is to return…

leetcodemediumdatabase
LeetCode 2603 - Collect Coins in a Tree

The problem is about collecting coins located on the nodes of a tree with the minimum number of edge traversals. We are given a tree with n nodes, represented by an edge list, and an array coins indicating whether a coin is present at each node.

leetcodehardarraytreegraph-theorytopological-sort
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
CF 201B - Guess That Car!

The problem places us in a grid-like parking lot of size 4·n by 4·m meters, divided into squares of 4 by 4 meters, each containing a car with a known "rarity" value.

codeforcescompetitive-programmingmathternary-search
LeetCode 2491 - Divide Players Into Teams of Equal Skill

This problem asks us to divide a given list of player skill levels into teams of exactly two players such that every team has the same total skill.

leetcodemediumarrayhash-tabletwo-pointerssorting
LeetCode 2270 - Number of Ways to Split Array

The problem asks us to determine the number of ways to split a given 0-indexed array nums into two non-empty contiguous subarrays such that the sum of the first part is greater than or equal to the sum of the second part.

leetcodemediumarrayprefix-sum
LeetCode 2192 - All Ancestors of a Node in a Directed Acyclic Graph

This problem gives us a Directed Acyclic Graph (DAG) with n nodes labeled from 0 to n - 1, along with a list of directed edges. Each edge [u, v] means there is a one way connection from node u to node v. The goal is to compute, for every node i, all of its ancestors.

leetcodemediumdepth-first-searchbreadth-first-searchgraph-theorytopological-sort
LeetCode 2179 - Count Good Triplets in an Array

In this problem, we are given two arrays, nums1 and nums2, each containing every integer from 0 to n - 1 exactly once. In other words, both arrays are permutations of the same set of values.

leetcodehardarraybinary-searchdivide-and-conquerbinary-indexed-treesegment-treemerge-sortordered-set
LeetCode 1961 - Check If String Is a Prefix of Array

The problem is asking us to determine whether a given string s can be formed by concatenating the first k elements of an array words, where k is some positive integer less than or equal to the length of words.

leetcodeeasyarraytwo-pointersstring
LeetCode 1854 - Maximum Population Year

The problem asks us to determine the year with the highest population given a list of birth and death years. Each element in the input logs is a pair [birthi, deathi] representing the inclusive start of life at birthi and exclusive end at deathi.

leetcodeeasyarraycountingprefix-sum
LeetCode 2111 - Minimum Operations to Make the Array K-Increasing

The problem asks us to transform a given array arr into a K-increasing array using the minimum number of operations. A K-increasing array is defined such that for every index i where i = k, the condition arr[i-k] <= arr[i] holds.

leetcodehardarraybinary-search
CF 437E - The Child and Polygon

We are asked to count how many ways a simple polygon with $n$ vertices can be triangulated. Triangulation here means splitting the polygon into triangles that exactly cover the polygon without overlap and without introducing new points.

codeforcescompetitive-programmingdpgeometry
LeetCode 3280 - Convert Date to Binary

The problem gives us a date string in the format yyyy-mm-dd. The year always has four digits, while the month and day always have two digits because of zero padding. We need to convert each of the three components, year, month, and day, into their binary representations.

leetcodeeasymathstring
LeetCode 2708 - Maximum Strength of a Group

The problem asks us to select a non-empty subset of integers from a given array nums such that the product of the numbers in the subset is maximized. Each number represents a student’s exam score, and the subset represents a group of students.

leetcodemediumarraydynamic-programmingbacktrackinggreedybit-manipulationsortingenumeration
LeetCode 1889 - Minimum Space Wasted From Packaging

The problem gives us a list of package sizes and several suppliers. Each supplier offers an unlimited number of boxes, but only in certain fixed sizes. We must choose exactly one supplier and pack every package using only the box sizes that supplier provides.

leetcodehardarraybinary-searchsortingprefix-sum
LeetCode 2177 - Find Three Consecutive Integers That Sum to a Given Number

This problem asks us to determine whether a given integer num can be represented as the sum of three consecutive integers. If such a representation exists, we must return those three integers in sorted order. Otherwise, we return an empty array.

leetcodemediummathsimulation
LeetCode 3143 - Maximum Points Inside the Square

The problem asks us to find the maximum number of points that can be contained in a square centered at the origin (0, 0) such that no two points inside the square share the same tag. The square's edges are parallel to the axes, and points on the edges are considered inside.

leetcodemediumarrayhash-tablestringbinary-searchsorting
LeetCode 2083 - Substrings That Begin and End With the Same Letter

The problem asks us to count all substrings in a given string s that start and end with the same character. A substring is a contiguous sequence of characters, so the order and adjacency of characters matter.

leetcodemediumhash-tablemathstringcountingprefix-sum
CF 420D - Cup Trick

We are given a line of cups, each cup carrying a unique label from 1 to n. The initial left-to-right order of these labels is unknown. What we do know is the exact sequence of m operations performed on this line.

codeforcescompetitive-programmingdata-structures
LeetCode 2239 - Find Closest Number to Zero

The problem gives us an integer array nums, and we need to return the number whose value is closest to 0. The phrase "closest to zero" means we compare numbers using their absolute values. For example: - |-2| = 2 - |5| = 5 Since 2 < 5, the number -2 is closer to zero than 5.

leetcodeeasyarray
LeetCode 2242 - Maximum Score of a Node Sequence

The problem gives us an undirected graph with n nodes. Each node has a score, and the graph edges define which nodes are directly connected. We must find a valid sequence of exactly four distinct nodes such that every adjacent pair in the sequence has an edge between them.

leetcodehardarraygraph-theorysortingenumeration
CF 265A - Colorful Stones (Simplified Edition)

The problem describes a row of stones, each colored red, green, or blue, represented by a string s of characters 'R', 'G', and 'B'. Squirrel Liss starts on the first stone and executes a sequence of color-based instructions, given by a second string t.

codeforcescompetitive-programmingimplementation
CF 166A - Rank List

We are given the final results of a programming contest. Each team has two values attached to it: how many problems it solved and its total penalty time. The ranking rule is the standard ICPC-style ordering. A team ranks higher if it solved more problems.

codeforcescompetitive-programmingbinary-searchimplementationsortings
LeetCode 1894 - Find the Student that Will Replace the Chalk

The problem presents a classroom scenario where students are given problems in a round-robin order, consuming a certain number of chalk pieces for each problem.

leetcodemediumarraybinary-searchsimulationprefix-sum
CF 182B - Vasya's Calendar

We are asked to simulate a peculiar kind of calendar. Vasya has a clock that shows days from 1 to d. Each month has a certain number of days, and the clock does not know which month it is.

codeforcescompetitive-programmingimplementation
LeetCode 2116 - Check if a Parentheses String Can Be Valid

This problem asks whether a given parentheses string can be transformed into a valid parentheses sequence under certain constraints. We are given two strings: - s, containing only '(' and ')' - locked, containing only '0' and '1' Both strings have the same length n.

leetcodemediumstringstackgreedy
LeetCode 3227 - Vowels Game in a String

The problem describes a two-player game between Alice and Bob played on a string s. Alice always moves first. The rules for each player are based on vowel counts in substrings: Alice can remove any non-empty substring containing an odd number of vowels, while Bob can remove…

leetcodemediummathstringbrainteasergame-theory
LeetCode 3254 - Find the Power of K-Size Subarrays I

The problem asks us to examine every contiguous subarray of length k in the input array nums and determine its "power". A subarray has valid power only if two conditions are simultaneously true: 1. The elements are sorted in strictly ascending order. 2.

leetcodemediumarraysliding-window
LeetCode 2051 - The Category of Each Member in the Store

This problem asks us to classify every store member into a category based on their shopping behavior. The classification depends on how often a member makes a purchase after visiting the store. We are given three database tables: - Members contains the list of all members.

leetcodemediumdatabase
LeetCode 2040 - Kth Smallest Product of Two Sorted Arrays

The problem asks for the k-th smallest product that can be formed by multiplying one element from the sorted array nums1 with one element from the sorted array nums2. Both arrays may contain negative numbers, zeros, and positive numbers.

leetcodehardarraybinary-search
LeetCode 3092 - Most Frequent IDs

The problem asks us to maintain a collection of IDs that is updated incrementally based on two arrays, nums and freq. Each index i represents a step.

leetcodemediumarrayhash-tableheap-(priority-queue)ordered-set
CF 163E - e-Government

We have a fixed set of surnames. Each surname can be either active or inactive. Initially every surname is active. The system must process three kinds of operations. A query +i activates the i-th surname. A query -i deactivates the i-th surname. A query ?

codeforcescompetitive-programmingdata-structuresdfs-and-similardpstringstrees
LeetCode 2441 - Largest Positive Integer That Exists With Its Negative

The problem asks us to find the largest positive integer k in a given array nums such that its negative counterpart -k also exists in the array. In other words, for each positive integer in the array, we need to check whether its negative exists.

leetcodeeasyarrayhash-tabletwo-pointerssorting
CF 216B - Forming Teams

We can model the students as an undirected graph. Each student is a vertex, and every pair of enemies creates an edge. We want to split the remaining students into two teams of equal size such that no edge stays inside one team.

codeforcescompetitive-programmingdfs-and-similarimplementation
LeetCode 2505 - Bitwise OR of All Subsequence Sums

This problem asks us to compute the bitwise OR of every possible subsequence sum of a given array. A subsequence is formed by choosing any subset of elements while preserving their original order.

leetcodemediumarraymathbit-manipulationbrainteaserprefix-sum
LeetCode 1911 - Maximum Alternating Subsequence Sum

The problem asks us to compute the maximum possible alternating sum of any subsequence of the given array. An alternating sum is calculated after the chosen subsequence is reindexed starting from index 0.

leetcodemediumarraydynamic-programming
LeetCode 2919 - Minimum Increment Operations to Make Array Beautiful

The problem asks us to transform an input integer array nums into a beautiful array by performing a minimum number of increment operations. An increment operation increases a single element of nums by 1.

leetcodemediumarraydynamic-programming
LeetCode 2885 - Rename Columns

This problem asks us to rename the column names of a Pandas DataFrame according to a fixed mapping. We are given a DataFrame named students with four columns: - id - first - last - age The goal is to return a DataFrame where these columns have been renamed to more descriptive…

leetcodeeasy
LeetCode 2672 - Number of Adjacent Elements With the Same Color

The problem gives us an array called colors of length n. Initially, every element is 0, which represents an uncolored position. We then process a sequence of queries.

leetcodemediumarray
LeetCode 2536 - Increment Submatrices by One

LeetCode 2536: Increment Submatrices by One (Medium)

leetcodemediumarraymatrixprefix-sum
LeetCode 1946 - Largest Number After Mutating Substring

This problem asks us to construct the lexicographically largest possible numeric string after optionally applying a single transformation operation on one contiguous substring of the input string num.

leetcodemediumarraystringgreedy
LeetCode 2454 - Next Greater Element IV

The problem asks us to compute, for every element in the array, its "second greater element" to the right. For an index i, we are interested in elements positioned after i. Among those elements, we only care about values strictly greater than nums[i].

leetcodehardarraybinary-searchstacksortingheap-(priority-queue)monotonic-stack
LeetCode 3136 - Valid Word

The problem asks us to determine whether a given string qualifies as a "valid word" according to four specific rules. First, the word must contain at least 3 characters. Any string shorter than 3 is automatically invalid.

leetcodeeasystring
CF 413D - 2048

We process a sequence of tiles, each tile being either 2 or 4. A tile starts far to the right and slides left. When it touches an equal value, the two merge into a doubled value and the new tile keeps moving.

codeforcescompetitive-programmingbitmasksdp
LeetCode 2377 - Sort the Olympic Table

This problem asks us to return the rows of the Olympic table in a very specific sorted order. Each row represents a country and the number of gold, silver, and bronze medals that country won in the Olympic games.

leetcodeeasydatabase
LeetCode 2019 - The Score of Students Solving Math Expression

The problem gives us a mathematical expression string s containing only: - Single digit numbers 0-9 - Addition operators + - Multiplication operators The expression is guaranteed to be valid.

leetcodehardarrayhash-tablemathstringdynamic-programmingstackmemoization
LeetCode 2529 - Maximum Count of Positive Integer and Negative Integer

The problem gives us a sorted integer array nums in non-decreasing order. Our task is to count how many numbers are positive and how many numbers are negative, then return the larger of the two counts.

leetcodeeasyarraybinary-searchcounting
LeetCode 3003 - Maximize the Number of Partitions After Operations

The problem asks us to take a string s and an integer k and compute the maximum number of partitions we can create from s under a specific set of operations. First, we are allowed to change at most one character in the string to any other lowercase English letter.

leetcodehardstringdynamic-programmingbit-manipulationbitmask
LeetCode 3010 - Divide an Array Into Subarrays With Minimum Cost I

The problem asks us to split a given array nums into exactly three disjoint contiguous subarrays and minimize the sum of their costs. The important detail is how cost is defined. The cost of a subarray is simply its first element.

leetcodeeasyarraysortingenumeration
CF 305A - Strange Addition

We are asked to select the largest possible subset of integers from a given set such that any two numbers in the subset can be summed by Vasya. Vasya’s summing rule is unusual: for each decimal place, at least one of the two numbers must have a zero in that place.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementation
LeetCode 2209 - Minimum White Tiles After Covering With Carpets

The problem presents a binary string floor representing a row of tiles, where '0' corresponds to a black tile and '1' corresponds to a white tile.

leetcodehardstringdynamic-programmingprefix-sum
CF 430A - Points and Segments (easy)

We are asked to color a set of points on a number line using two colors, red and blue, so that for each given segment, the number of red and blue points inside that segment differ by at most one.

codeforcescompetitive-programmingconstructive-algorithmssortings
LeetCode 2617 - Minimum Number of Visited Cells in a Grid

The problem asks us to determine the minimum number of cells we need to visit in order to reach the bottom-right corner of a given m x n grid. Each cell (i, j) contains a number grid[i][j] representing the maximum number of steps we can move right or down from that cell.

leetcodehardarraydynamic-programmingstackbreadth-first-searchunion-findheap-(priority-queue)matrixmonotonic-stack
LeetCode 2767 - Partition String Into Minimum Beautiful Substrings

The problem asks us to partition a given binary string s into the minimum number of substrings such that each substring is beautiful. A substring is beautiful if it represents a power of 5 in decimal and does not have leading zeros.

leetcodemediumhash-tablestringdynamic-programmingbacktracking
LeetCode 1924 - Erect the Fence II

Here is a fully detailed technical solution guide for LeetCode 1924 - Erect the Fence II, following your formatting instructions: The problem asks us to compute the minimum enclosing circle for a set of points in 2D space, where each point represents a tree.

leetcodehardarraymathgeometry
CF 186A - Comparing Strings

We are given two strings representing the genomes of two dwarves. The goal is to determine whether these two genomes could belong to the same race under a very specific definition: the first genome can be transformed into the second genome by swapping exactly two characters in…

codeforcescompetitive-programmingimplementationstrings
LeetCode 2115 - Find All Possible Recipes from Given Supplies

This problem asks us to determine which recipes can be created when we start with a set of available supplies and are allowed to recursively create additional recipes. Each recipe has a list of required ingredients.

leetcodemediumarrayhash-tablestringgraph-theorytopological-sort
CF 147B - Smile House

We are given a set of rooms connected by doors, where each door has two mood values: one for each direction. Petya can move from room to room, and every move adds to his mood according to the direction-specific value.

codeforcescompetitive-programmingbinary-searchgraphsmatrices
CF 226B - Naughty Stone Piles

We have several stone piles, each with some initial size. One operation chooses a source pile and merges it into another pile. The source pile disappears, the destination pile grows, and the operation cost equals the current size of the source pile.

codeforcescompetitive-programminggreedy