brain

tamnd's digital brain — notes, problems, research

42616 notes

LeetCode 2644 - Find the Maximum Divisibility Score

The problem asks us to identify, from a list of divisors, the integer that has the maximum divisibility score with respect to a given array of numbers. The divisibility score of a divisor is defined as the count of elements in nums that are divisible by that divisor.

leetcodeeasyarray
LeetCode 2415 - Reverse Odd Levels of Binary Tree

The problem asks us to reverse the values of nodes at odd levels of a perfect binary tree. A perfect binary tree is a tree in which every parent node has exactly two children and all leaves appear at the same depth.

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 3306 - Count of Substrings Containing Every Vowel and K Consonants II

The problem asks us to count how many substrings of a given string satisfy two conditions simultaneously: 1. The substring contains all five vowels, 'a', 'e', 'i', 'o', and 'u', at least once. 2. The substring contains exactly k consonants.

leetcodemediumhash-tablestringsliding-window
LeetCode 3265 - Count Almost Equal Pairs I

The problem asks us to find the number of index pairs (i, j) in an array nums such that i < j and the integers nums[i] and nums[j] are almost equal.

leetcodemediumarrayhash-tablesortingcountingenumeration
CF 420C - Bug in Code

Each participant in the company meeting points to two other people and claims that the culprit is one of those two. From this we can think of the input as an array of length $n$, where each index $i$ stores an unordered pair $(xi, yi)$.

codeforcescompetitive-programmingdata-structuresgraphsimplementationtwo-pointers
LeetCode 3367 - Maximize Sum of Weights after Edge Removals

We are given an undirected weighted tree with n nodes and n - 1 edges. Since the graph is a tree, there is exactly one simple path between any pair of nodes, and there are no cycles. Each edge has a weight, and we may remove any number of edges.

leetcodeharddynamic-programmingtreedepth-first-searchsorting
CF 160B - Unlucky Ticket

We are given a ticket represented as a string of 2n digits, where n is between 1 and 100. The first half of the ticket contains the first n digits and the second half contains the remaining n digits. We are asked to determine whether the ticket is “definitely unlucky.

codeforcescompetitive-programminggreedysortings
LeetCode 2865 - Beautiful Towers I

The problem asks us to transform an array of tower heights into a mountain-shaped arrangement while removing as few bricks as necessary.

leetcodemediumarraystackmonotonic-stack
LeetCode 2325 - Decode the Message

This problem is asking us to decode a secret message using a substitution cipher defined by a key string. The key string may include spaces and contains every lowercase letter of the English alphabet at least once.

leetcodeeasyhash-tablestring
CF 263B - Squares

Codeforces 263B: Squares

codeforcescompetitive-programminggreedyimplementationsortings
LeetCode 3316 - Find Maximum Removals From Source String

We are given three inputs: - source, the original string of length n - pattern, a string that is guaranteed to already be a subsequence of source - targetIndices, a sorted list of indices in source that are eligible for removal An operation consists of removing a character…

leetcodemediumarrayhash-tabletwo-pointersstringdynamic-programming
LeetCode 2766 - Relocate Marbles

The problem gives us an array nums representing the positions of marbles on a number line. Multiple marbles may exist at the same position, so nums can contain duplicates. We are also given two arrays, moveFrom and moveTo, which describe a sequence of move operations.

leetcodemediumarrayhash-tablesortingsimulation
CF 158B - Taxi

We have a collection of schoolchildren organized into groups, and each group wants to travel together in a taxi. Each group has between one and four children, and each taxi can carry at most four children.

codeforcescompetitive-programming*specialgreedyimplementation
LeetCode 3249 - Count the Number of Good Nodes

We are given an undirected tree with n nodes labeled from 0 to n - 1. The tree is rooted at node 0, which means every node except the root has exactly one parent, and each node may have zero or more children. The task is to count how many nodes are considered "good".

leetcodemediumtreedepth-first-search
LeetCode 3068 - Find the Maximum Sum of Node Values

You are given a tree with n nodes. Every node has a value stored in the array nums, and every edge connects two nodes in an undirected manner.

leetcodehardarraydynamic-programminggreedybit-manipulationtreesorting
LeetCode 3012 - Minimize Length of Array Using Operations

The problem gives us a 0-indexed array of positive integers and asks us to repeatedly perform a specific operation to reduce the array's length as much as possible.

leetcodemediumarraymathgreedynumber-theory
LeetCode 2247 - Maximum Cost of Trip With K Highways

The problem gives us an undirected weighted graph with n cities and a list of highways. Each highway connects two cities and has an associated toll cost. We must find the maximum possible total toll for a trip that uses exactly k highways. There are two important restrictions: 1.

leetcodeharddynamic-programmingbit-manipulationgraph-theorybitmask
LeetCode 3208 - Alternating Groups II

The problem gives us a circular array called colors, where each value represents a tile color. A value of 0 means red, and a value of 1 means blue. We are also given an integer k. We must count how many groups of exactly k contiguous tiles form an alternating sequence.

leetcodemediumarraysliding-window
CF 253C - Text Editor

We are given a text editor that stores several lines of text. Each line has a known length, and the cursor is allowed to sit not only on characters but also in the gap positions before the first character and after the last character.

codeforcescompetitive-programmingdata-structuresdfs-and-similargraphsgreedyshortest-paths
LeetCode 3161 - Block Placement Queries

The problem involves simulating operations on an infinite number line starting at 0 and extending towards the positive x-axis.

leetcodehardarraybinary-searchbinary-indexed-treesegment-tree
LeetCode 3122 - Minimum Number of Operations to Satisfy Conditions

The problem presents a two-dimensional matrix grid of size m x n with integer values in the range 0 to 9. The task is to transform this matrix using the minimum number of operations, where each operation allows you to change the value of any cell to any non-negative integer.

leetcodemediumarraydynamic-programmingmatrix
LeetCode 3175 - Find The First Player to win K Games in a Row

The problem describes a competition where players stand in a queue and repeatedly compete against each other. Every player has a unique skill value, and whenever two players play, the one with the larger skill always wins. At each step: 1.

leetcodemediumarraysimulation
LeetCode 3114 - Latest Time You Can Obtain After Replacing Characters

The problem gives us a string representing a time in 12-hour format using the pattern "HH:MM". Some characters may already be fixed digits, while others are replaced with "?". Our task is to replace every "?

leetcodeeasystringenumeration
LeetCode 1964 - Find the Longest Valid Obstacle Course at Each Position

The problem gives an array obstacles, where each value represents the height of an obstacle. For every position i, we must determine the length of the longest valid obstacle course that ends exactly at index i.

leetcodehardarraybinary-searchbinary-indexed-tree
LeetCode 2931 - Maximum Spending After Buying Items

We are given an m × n matrix values where each row represents a shop and each column represents an item in that shop. The important property is that every row is sorted in non-increasing order: When buying from a shop, we are not allowed to choose any arbitrary item.

leetcodehardarraygreedysortingheap-(priority-queue)matrix
LeetCode 2842 - Count K-Subsequences of a String With Maximum Beauty

The problem requires us to count k-subsequences of a string s that have the maximum beauty, where beauty is defined as the sum of the frequency of each character in the subsequence. A k-subsequence is a subsequence of length k where all characters are unique.

leetcodehardhash-tablemathstringgreedysortingcombinatorics
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 2171 - Removing Minimum Number of Magic Beans

The problem asks us to remove beans from bags in such a way that all non-empty bags have the same number of beans while minimizing the total number of beans removed. Each element in the input array beans represents a bag with a positive number of beans.

leetcodemediumarraygreedysortingenumerationprefix-sum
LeetCode 3358 - Books with NULL Ratings

This problem provides a database table named books. Each row in the table represents a single book and contains information such as the book's ID, title, author, publication year, and rating. The important detail is that the rating column can contain NULL values.

leetcodeeasydatabase
LeetCode 2282 - Number of People That Can Be Seen in a Grid

The problem asks us to determine, for each person in a 2D grid of heights, how many other people they can see according to a specific line-of-sight rule.

leetcodemediumarraystackmatrixmonotonic-stack
LeetCode 2567 - Minimum Score by Changing Two Elements

The problem asks us to manipulate an array of integers, nums, in a very specific way to minimize a metric called the "score.

leetcodemediumarraygreedysorting
CF 306C - White, Black and White Again

We are asked to compute the number of ways to distribute a set of good and not-so-good events across a sequence of days divided into three consecutive segments: a white segment, a black segment, and a second white segment.

codeforcescompetitive-programmingcombinatoricsnumber-theory
CF 165B - Burning Midnight Oil

Vasya has to write at least n lines of code during one night. He starts with productivity v, meaning he writes v lines before the first tea break. After every break, his productivity drops by a factor of k, using integer division.

codeforcescompetitive-programmingbinary-searchimplementation
LeetCode 2286 - Booking Concert Tickets in Groups

The problem asks us to design a ticket reservation system for a concert hall. The hall contains n rows, and each row contains exactly m seats. Seats in every row are numbered from left to right starting at 0.

leetcodehardbinary-searchdesignbinary-indexed-treesegment-tree
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 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
LeetCode 3059 - Find All Unique Email Domains

This problem asks us to analyze email addresses stored in a database table and determine how many people belong to each unique email domain, but only for domains ending in .com.

leetcodeeasydatabase
CF 163D - Large Refrigerator

We need to build a rectangular box with integer side lengths a, b, and c. Its volume must equal a given number V, and among all such integer triples we want the one with minimum surface area.

codeforcescompetitive-programmingbrute-force
LeetCode 2492 - Minimum Score of a Path Between Two Cities

The problem asks us to find the minimum possible score of a path between city 1 and city n in a graph defined by n cities and roads. Each road connects two cities bidirectionally and has an associated distance.

leetcodemediumdepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 2188 - Minimum Time to Finish the Race

The problem asks us to find the minimum total time to complete a race of numLaps laps using a collection of tires, where each tire has two parameters: a base lap time fi and a multiplier ri.

leetcodehardarraydynamic-programming
LeetCode 3082 - Find the Sum of the Power of All Subsequences

You are given an array nums and an integer k. For every subsequence of nums, we define its power as the number of subsequences inside it whose sum equals k. The task is to compute the total power across all subsequences of the original array.

leetcodehardarraydynamic-programming
LeetCode 1978 - Employees Whose Manager Left the Company

The problem is asking us to find employees in a company who meet two specific conditions. First, their salary must be strictly less than $30,000.

leetcodeeasydatabase
LeetCode 2081 - Sum of k-Mirror Numbers

The problem asks us to find the sum of the n smallest k-mirror numbers, where a k-mirror number is a positive integer that reads the same forwards and backwards both in base-10 and in base-k.

leetcodehardmathenumeration
LeetCode 2621 - Sleep

The problem asks us to implement an asynchronous function sleep that pauses execution for a given number of milliseconds, specified by the input millis.

leetcodeeasy
CF 354D - Transferring Pyramid

We are given a triangular pyramid structure made of cells arranged in rows. The first row has one cell, the second row has two, and so on, up to n rows. Each cell can hold a value.

codeforcescompetitive-programmingdp
LeetCode 2473 - Minimum Cost to Buy Apples

The problem asks us to determine the minimum cost to buy exactly one apple starting from each city in a network of cities connected by bidirectional roads. Each city has a specific cost for buying an apple, and each road has a travel cost.

leetcodemediumarraygraph-theoryheap-(priority-queue)shortest-path
CF 226D - The table

We are given a rectangular table of integers with $n$ rows and $m$ columns. Each cell contains a number that could be positive, negative, or zero. Harry can perform two types of operations: flip the sign of all numbers in a row or flip the sign of all numbers in a column.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
LeetCode 2910 - Minimum Number of Groups to Create a Valid Assignment

This problem gives us an array of integers representing balls. Balls with the same value are indistinguishable for grouping purposes, and every group must contain balls of only one value. The challenge comes from the balancing constraint.

leetcodemediumarrayhash-tablegreedy
LeetCode 2782 - Number of Unique Categories

This problem asks us to determine how many distinct categories exist among n elements. The elements are labeled from 0 to n - 1, but we are not given the category values directly.

leetcodemediumunion-findinteractivecounting
LeetCode 2525 - Categorize Box According to Criteria

The problem requires categorizing a box based on its dimensions and mass according to given criteria. We are given four integers: length, width, height, and mass. The output is a string that represents the category of the box: "Bulky", "Heavy", "Both", or "Neither".

leetcodeeasymath
LeetCode 2794 - Create Object from Two Arrays

The problem provides two arrays, keysArr and valuesArr, which always have the same length. Each position in the arrays represents a potential key-value pair.

leetcodeeasy
CF 443A - Anton and Letters

We are given a single formatted string that represents a set of lowercase English letters. The set is written in a very specific textual form: it starts with an opening brace, ends with a closing brace, and inside the braces letters are listed separated by comma and space.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
LeetCode 2291 - Maximum Profit From Trading Stocks

The problem gives us two arrays, present and future, where each index represents a stock. The value present[i] is the price of buying the i-th stock today, while future[i] is the price at which the same stock can be sold one year later.

leetcodemediumarraydynamic-programming
LeetCode 2475 - Number of Unequal Triplets in Array

The problem gives us a 0-indexed integer array nums, and we must count how many triplets (i, j, k) satisfy two conditions.

leetcodeeasyarrayhash-tablesorting
LeetCode 3348 - Smallest Divisible Digit Product II

The problem asks us to find the smallest number that satisfies several constraints relative to a given number num and a target integer t. The input num is a string representing a positive integer, and the number must be zero-free, meaning none of its digits are zero.

leetcodehardmathstringbacktrackinggreedynumber-theory
CF 150B - Quantity of Strings

We want to count strings of length n built from an alphabet of size m, under one strong restriction: every substring of length k must be a palindrome.

codeforcescompetitive-programmingcombinatoricsdfs-and-similargraphsmath
LeetCode 2660 - Determine the Winner of a Bowling Game

The problem describes a simplified scoring system for a bowling game between two players. Each player has an array representing the number of pins hit in each turn, and there are exactly n turns.

leetcodeeasyarraysimulation
LeetCode 2489 - Number of Substrings With Fixed Ratio

The problem gives us a binary string s, along with two coprime integers num1 and num2. We need to count how many non-empty substrings contain 0s and 1s in the exact ratio num1 : num2.

leetcodemediumhash-tablemathstringprefix-sum
LeetCode 2424 - Longest Uploaded Prefix

The problem asks us to design a data structure that tracks uploaded videos and continuously reports the length of the longest uploaded prefix. A prefix of uploaded videos means that every video from 1 through i has already been uploaded. The goal is to return the maximum such i.

leetcodemediumhash-tablebinary-searchunion-finddesignbinary-indexed-treesegment-treeheap-(priority-queue)ordered-set
LeetCode 1953 - Maximum Number of Weeks for Which You Can Work

The problem gives us an array called milestones, where each value represents how many milestones belong to a particular project. Every week, we must complete exactly one milestone from one project.

leetcodemediumarraygreedy
LeetCode 3008 - Find Beautiful Indices in the Given Array II

This problem asks us to find every starting index where the substring a appears inside the string s, subject to an additional proximity condition involving another substring b. More specifically, an index i is considered beautiful if two conditions hold: 1.

leetcodehardtwo-pointersstringbinary-searchrolling-hashstring-matchinghash-function
LeetCode 3185 - Count Pairs That Form a Complete Day II

The problem asks us to count pairs of elements in an integer array hours such that the sum of the two elements is a multiple of 24, which we call a "complete day." Each pair (i, j) must satisfy i < j.

leetcodemediumarrayhash-tablecounting
LeetCode 2214 - Minimum Health to Beat Game

The problem presents a sequential game consisting of n levels, where each level inflicts a specific amount of damage to the player. You are given a list damage where damage[i] represents the damage from level i.

leetcodemediumarraygreedy
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 2742 - Painting the Walls

The problem is asking us to determine the minimum total cost to paint n walls using two painters with different constraints. We are given two arrays: cost and time, both of size n.

leetcodehardarraydynamic-programming
LeetCode 3382 - Maximum Area Rectangle With Point Constraints II

The problem asks us to find the maximum area rectangle that can be formed from a given set of points on a 2D plane, under strict constraints.

leetcodehardarraymathbinary-indexed-treesegment-treegeometrysorting
LeetCode 2835 - Minimum Operations to Form Subsequence With Target Sum

The problem presents a 0-indexed array nums of non-negative powers of 2 and an integer target. Each element in nums is guaranteed to be a power of two, which is important because it allows us to reason about sums and splits in terms of binary representation.

leetcodehardarraygreedybit-manipulation
LeetCode 2045 - Second Minimum Time to Reach Destination

Here is a comprehensive technical solution guide for LeetCode 2045 following your requested format: The problem asks us to find the second minimum time to travel from vertex 1 to vertex n in a weighted, undirected graph, where the weight of every edge is the same (time).

leetcodehardbreadth-first-searchgraph-theoryshortest-path
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 2082 - The Number of Rich Customers

The problem gives us a database table named Store. Each row in the table represents a single bill issued to a customer.

leetcodeeasydatabase
CF 421A - Pasha and Hamsters

We are given a line of apples numbered from 1 to n. Each apple can be given to exactly one of two hamsters, Arthur or Alexander. The only restriction is that Arthur must receive only apples he likes, and Alexander must receive only apples he likes.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
LeetCode 2830 - Maximize the Profit as the Salesman

This problem gives us n houses arranged on a number line and a collection of purchase offers. Each offer is represented as [start, end, gold], meaning a buyer wants to purchase every house in the inclusive range [start, end] and is willing to pay gold units of gold.

leetcodemediumarrayhash-tablebinary-searchdynamic-programmingsorting
LeetCode 2340 - Minimum Adjacent Swaps to Make a Valid Array

The previous solution fails immediately under a counterexample check. The proposed path was the union of the segments from to the midpoints of and . If the side length is , then the detector radius is The distance from to that path is , while Hence is not detected at all.

leetcodemediumarraygreedy
CF 253D - Table with Letters - 2

We are given a rectangular grid of characters, each cell containing a lowercase English letter. The task is to count how many axis-aligned subrectangles have two properties at the same time.

codeforcescompetitive-programmingbrute-forcetwo-pointers
CF 201E - Thoroughly Bureaucratic Organization

The problem involves a set of people, each with an appointment on a unique day in the next n days. You do not know who is scheduled on which day, but you can query the organization in forms that list up to m names.

codeforcescompetitive-programmingbinary-searchcombinatorics
CF 416C - Booking System

We are given a collection of booking requests, where each request represents a group of guests who either all get seated together or do not come at all.

codeforcescompetitive-programmingbinary-searchdpgreedyimplementation
LeetCode 2419 - Longest Subarray With Maximum Bitwise AND

The problem asks us to find the length of the longest subarray within a given array nums such that the bitwise AND of all elements in that subarray is maximized.

leetcodemediumarraybit-manipulationbrainteaser
CF 160A - Twins

We are given a collection of coins, each with a positive integer value. The task is to choose a subset of these coins such that the total value of our chosen coins is strictly greater than the total value of the coins left for the other person.

codeforcescompetitive-programminggreedysortings
CF 142A - Help Farmer

After the theft, the barn contains a smaller rectangular box of hay blocks. If the original dimensions were $A times B times C$, then the remaining pile has dimensions $(A-1) times (B-2) times (C-2)$.

codeforcescompetitive-programmingbrute-forcemath
LeetCode 2868 - The Wording Game

The problem describes a turn-based game between Alice and Bob, where both players have a lexicographically sorted list of words. Alice always starts by playing her lexicographically smallest word, and the players then alternate turns.

leetcodehardarraymathtwo-pointersstringgreedygame-theory
LeetCode 2185 - Counting Words With a Given Prefix

The problem gives us two inputs: - An array of strings called words - A string called pref We must count how many strings inside words start with the string pref. A prefix means the beginning portion of a string.

leetcodeeasyarraystringstring-matching
LeetCode 2184 - Number of Ways to Build Sturdy Brick Wall

The problem asks us to compute the number of ways to build a wall of given height and width using bricks of specified widths, such that the wall is sturdy.

leetcodemediumarraydynamic-programmingbit-manipulationbitmask
LeetCode 2234 - Maximum Total Beauty of the Gardens

In this problem, we are given several gardens, where flowers[i] represents how many flowers are already planted in the i-th garden. We are also given a limited number of additional flowers, newFlowers, that we may distribute among the gardens.

leetcodehardarraytwo-pointersbinary-searchgreedysortingenumerationprefix-sum
LeetCode 2867 - Count Valid Paths in a Tree

That is a long, structured reference document with multiple required sections, detailed prose, two full implementations, worked examples, test cases, and edge-case analysis. To keep quality high and avoid truncation, I will provide it in a complete guide format.

leetcodehardmathdynamic-programmingtreedepth-first-searchnumber-theory
CF 137D - Palindromes

We are given a string and an integer k. We may change any characters we want, and the goal is to transform the string into a concatenation of at most k palindromes while minimizing the number of modified characters. The partition boundaries are not fixed.

codeforcescompetitive-programmingdpstrings
LeetCode 2230 - The Users That Are Eligible for Discount

This problem asks us to identify all users who qualify for a discount based on their purchase history stored in the Purchases table.

leetcodeeasydatabase
LeetCode 3102 - Minimize Manhattan Distances

The problem asks us to minimize the maximum Manhattan distance between any two points on a 2D plane after removing exactly one point from the input list. The input points is an array of integer coordinates [[x1, y1], [x2, y2], ..., [xn, yn]].

leetcodehardarraymathgeometrysortingordered-set
LeetCode 3177 - Find the Maximum Length of a Good Subsequence II

We are given an integer array nums and a non-negative integer k. We must find the maximum possible length of a subsequence such that the number of adjacent unequal pairs is at most k.

leetcodehardarrayhash-tabledynamic-programming
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
LeetCode 2301 - Match Substring After Replacement

The problem gives us a string s, a target string sub, and a list of character replacement rules called mappings. Each mapping [old, new] means that a character old inside sub may be replaced with new.

leetcodehardarrayhash-tablestringstring-matching
LeetCode 2428 - Maximum Sum of an Hourglass

The problem provides an m x n integer matrix grid and asks for the maximum sum of an hourglass shape within the matrix. An hourglass is defined as a 3x3 structure with the top and bottom rows fully included, and only the center element from the middle row.

leetcodemediumarraymatrixprefix-sum
LeetCode 1934 - Confirmation Rate

This problem asks us to calculate the confirmation rate for each user in a system where users can request confirmation messages after signing up. We are given two tables: Signups and Confirmations.

leetcodemediumdatabase
LeetCode 2545 - Sort the Students by Their Kth Score

In this problem, we are given a matrix named score with dimensions m x n. Each row represents a student, and each column represents an exam. The value score[i][j] is the score obtained by the ith student on the jth exam.

leetcodemediumarraysortingmatrix
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 1998 - GCD Sort of an Array

The problem asks whether it is possible to sort an integer array nums into non-decreasing order using a very specific type of swap. You can swap any two elements nums[i] and nums[j] if and only if their greatest common divisor (GCD) is greater than 1.

leetcodehardarraymathunion-findsortingnumber-theory
LeetCode 3287 - Find the Maximum Sequence Value of Array

We are given an array nums and an integer k. We must choose a subsequence of exactly 2 k elements while preserving the original order of the array. After selecting the subsequence, we split it into two equal halves: - The first k selected elements form the left group.

leetcodehardarraydynamic-programmingbit-manipulation
CF 215D - Hot Days

We are asked to transport a group of schoolchildren through a sequence of regions along a single road. Each region has a fixed outdoor temperature and a maximum tolerable bus temperature. Every child inside a bus above that tolerable temperature triggers a monetary penalty.

codeforcescompetitive-programminggreedy
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 150E - Freezing with Style

We are given a tree with n junctions and n - 1 roads. Every road has an integer beauty value. We must choose two junctions so that the path between them contains between l and r edges inclusive.

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquertrees
LeetCode 3317 - Find the Number of Possible Ways for an Event

The problem describes an event with n performers and x available stages. Each performer must be assigned to exactly one stage. Multiple performers may share the same stage, which means they form a band together. Some stages may remain unused.

leetcodehardmathdynamic-programmingcombinatorics