brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 3931 - Check Adjacent Digit Differences

The problem asks us to determine whether the absolute difference between every pair of adjacent digits in a given string s is at most 2. The input s is a string of digits, with a minimum length of 2 and a maximum of 100.

leetcodeeasystring
LeetCode 3928 - Minimum Cost to Buy Apples II

The problem asks us to determine the minimum cost to purchase apples starting from each shop, taking into account two types of costs: the local price of apples at each shop and the transportation costs along roads connecting the shops.

leetcodehardarraygraph-theoryheap-(priority-queue)shortest-path
LeetCode 3927 - Minimize Array Sum Using Divisible Replacements

The problem gives an integer array nums and allows an operation that can reduce values under a divisibility condition. Specifically, you may choose two indices a and b such that nums[a] % nums[b] == 0, and then replace nums[a] with nums[b].

leetcodemediumarrayhash-tablemathgreedynumber-theory
LeetCode 3925 - Concatenate Array With Reverse

The problem asks us to construct a new array by concatenating an input array with its reversed version. Given an integer array nums of length n, we must return a new array ans of length 2 n. The first n elements of ans are exactly the same as nums, preserving order.

leetcodeeasyarraysimulation
LeetCode 3904 - Smallest Stable Index II

The problem gives an integer array nums of length n and an integer k. For every index i, we split the array into two overlapping parts: - The prefix nums[0..i] - The suffix nums[i..

leetcodemediumarrayprefix-sum
LeetCode 3923 - Minimum Generations to Target Point

This problem defines a process that repeatedly creates new 3D points from existing points. We begin with the given list points, which forms generation 0.

leetcodemediumarrayhash-tablesimulation
Kvant Physics Problem 318

The circuit in Fig.

kvantphysics
LeetCode 3921 - Score Validator

This problem asks us to simulate a simple scoring system while processing a sequence of event strings from left to right. We are given an array called events, where each element represents one event.

leetcodeeasyarraystringsimulation
CF 1552G - A Serious Referee

We are asked to determine if a specific sequence of partial sorts can guarantee that any array of length $n$ will be fully sorted at the end. The input specifies $n$, the size of the array, and $k$, the number of sorting steps Andrea performs.

codeforcescompetitive-programmingbitmasksbrute-forcedfs-and-similarsortings
LeetCode 3920 - Maximize Fixed Points After Deletions

The problem asks us to maximize the number of fixed points in an array after performing deletions. A fixed point is an index i such that nums[i] == i.

leetcodehardarraybinary-searchsorting
LeetCode 3919 - Minimum Cost to Move Between Indices

We are given a strictly increasing array nums. Each position represents an index in the array, and we want to move between indices as cheaply as possible. For every index x, a special neighbor called closest(x) is defined.

leetcodemediumarraygreedyprefix-sum
LeetCode 3918 - Sum of Primes Between Number and Its Reverse

The problem gives us a single integer n. We first construct another integer r by reversing the digits of n. For example: - If n = 13, then r = 31 - If n = 10, then r = 1 - If n = 120, then r = 21 Once we have both numbers, we consider the inclusive range between them.

leetcodemediummathnumber-theory
LeetCode 3917 - Count Indices With Opposite Parity

The problem gives us an integer array nums of length n. For every index i, we must determine how many indices to its right contain a number with the opposite parity. Parity refers to whether a number is even or odd: - Even numbers have a remainder of 0 when divided by 2.

leetcodeeasyarray
CF 1552B - Running for Gold

Each athlete is described by five rankings, one ranking from each past marathon. Smaller values are better because a rank of 1 means first place. For two athletes x and y, we say that x is superior to y if x has a better rank in at least three of the five marathons.

codeforcescompetitive-programmingcombinatoricsgraphsgreedysortings
LeetCode 3914 - Minimum Operations to Make Array Non Decreasing

We are given an array nums. In a single operation, we choose any contiguous subarray and increase every element in that subarray by the same positive integer value x. The cost of an operation is exactly the chosen value x.

leetcodemediumarraygreedy
LeetCode 3915 - Maximum Sum of Alternating Subsequence With Distance at Least K

The solution does address the correct exercise and correctly identifies that the task is to generalize Algorithm S by handling the case when subtraction is performed without knowing which operand is larger.

leetcodehardarraydynamic-programmingsegment-tree
LeetCode 3913 - Sort Vowels by Frequency

The problem requires us to reorder the vowels in a given string s based on their frequency, while keeping all consonants in their original positions. Specifically, the vowels must appear in non-increasing order of frequency.

leetcodemediumstringsortingcounting
LeetCode 3912 - Valid Elements in an Array

The solution does address the correct exercise and correctly identifies that the task is to generalize Algorithm S by handling the case when subtraction is performed without knowing which operand is larger.

leetcodeeasyarray
LeetCode 3911 - K-th Smallest Remaining Even Integer in Subarray Queries

The problem provides a strictly increasing integer array nums and a list of queries, each consisting of [li, ri, ki]. For each query, we consider the subarray nums[li..ri] and remove all elements of this subarray from the infinite sequence of positive even integers.

leetcodehardarraybinary-search
CF 1553H - XOR and Distance

We have a set of distinct integers $a1,dots,an$, each lying in the range $[0,2^k)$. For every mask $x$, we XOR every array element with $x$, producing the set $${a1oplus x,dots,anoplus x}.$$ Among all pairs in that transformed set, we want the smallest absolute difference.

codeforcescompetitive-programmingbitmasksdivide-and-conquertrees
LeetCode 3909 - Compare Sums of Bitonic Parts

The problem gives us a bitonic array nums, meaning an array that first strictly increases to a single peak element and then strictly decreases. The task is to split this array into two overlapping parts: 1.

leetcodemediumarray
LeetCode 3910 - Count Connected Subgraphs with Even Node Sum

The solution does address the correct exercise and correctly identifies that the task is to generalize Algorithm S by handling the case when subtraction is performed without knowing which operand is larger.

leetcodehardarraybit-manipulationdepth-first-searchbreadth-first-searchunion-findgraph-theoryenumeration
LeetCode 3908 - Valid Digit Number

The problem is asking us to determine whether a given integer n is valid with respect to a digit x based on two conditions. First, n must contain at least one occurrence of the digit x. Second, n must not start with digit x.

leetcodeeasymath
Kvant Physics Problem 319

A luminous object is placed on the optical axis of a thin converging lens $\text{Л}_1$ with focal length $F$.

kvantphysics
LeetCode 3906 - Count Good Integers on a Grid Path

The solution does address the correct exercise and correctly identifies that the task is to generalize Algorithm S by handling the case when subtraction is performed without knowing which operand is larger.

leetcodeharddynamic-programming
LeetCode 3905 - Multi Source Flood Fill

The problem asks us to simulate a multi-source flood fill on an n x m grid. Each element of the sources array represents a starting point with a specific color, and all other cells start uncolored, represented as 0.

leetcodemediumarraybreadth-first-searchmatrix
LeetCode 3903 - Smallest Stable Index I

The problem asks us to find the smallest index i in an integer array nums such that the instability score at that index is less than or equal to a given integer k. The instability score is defined as the difference between the maximum of the prefix nums[0..

leetcodeeasyarrayprefix-sum
LeetCode 3901 - Good Subsequence Queries

The solution does address the correct exercise and correctly identifies that the task is to generalize Algorithm S by handling the case when subtraction is performed without knowing which operand is larger.

leetcodehard
CF 1553C - Penalty

We are simulating a penalty shootout between two football teams, each taking alternating kicks up to five each, for a total of ten kicks. Each kick either succeeds (scores a goal), fails, or is unknown.

codeforcescompetitive-programmingbitmasksbrute-forcedpgreedy
Kvant Physics Problem 315

A wire spiral is connected to an ideal constant-voltage mains source with voltage $V$.

kvantphysics
LeetCode 3900 - Longest Balanced Substring After One Swap

We are given a binary string s containing only '0' and '1'. A substring is considered balanced when it contains exactly the same number of zeros and ones. Before choosing the substring, we are allowed to perform at most one swap between any two positions in the entire string.

leetcodemedium
LeetCode 3898 - Find the Degree of Each Vertex

The problem asks us to calculate the degree of each vertex in an undirected graph represented by an adjacency matrix. The input is a 2D integer array matrix of size n x n, where matrix[i][j] = 1 indicates an edge between vertices i and j, and matrix[i][j] = 0 indicates no edge.

leetcodeeasy
LeetCode 3897 - Maximum Value of Concatenated Binary Segments

The problem presents two integer arrays nums1 and nums0, each of size n. Each index i represents a binary segment consisting of a number of '1' bits followed by a number of '0' bits.

leetcodehard
LeetCode 3895 - Count Digit Appearances

The problem asks us to count how many times a specific decimal digit appears when writing out every number in the array. We are given an integer array nums and a single digit between 0 and 9.

leetcodemedium
LeetCode 3894 - Traffic Signal Color

This problem asks us to determine the current state of a traffic signal based on an integer timer that represents the remaining seconds for the signal.

leetcodeeasy
LeetCode 3896 - Minimum Operations to Transform Array into Alternating Prime

The problem asks us to transform an integer array nums into an alternating prime array, where numbers at even indices are prime and numbers at odd indices are non-prime.

leetcodemedium
LeetCode 3892 - Minimum Operations to Achieve At Least K Peaks

We are given a circular array nums. An index is considered a peak if its value is strictly greater than both of its neighbors. Because the array is circular, the first and last elements are adjacent. For example, the neighbors of index 0 are nums[n - 1] and nums[1].

leetcodehardarraydynamic-programming
LeetCode 3887 - Incremental Even-Weighted Cycle Queries

This problem describes a dynamic process of building an undirected graph with weighted edges where the weights are binary, either 0 or 1. You start with n isolated nodes labeled from 0 to n-1.

leetcodehardunion-findgraph-theory
LeetCode 3886 - Sum of Sortable Integers

The problem asks us to find all integers k that divide the length of the input array nums and for which the array can be sorted into non-decreasing order using a very specific operation.

leetcodehardarraymathsortingenumeration
LeetCode 3849 - Maximum Bitwise XOR After Rearrangement

Exercise 4.3.1.9 asks for a generalization of Algorithm A to add two -place numbers in a mixed-radix system with bases from right to left. Algorithm A in TAOCP §4.3.1 describes standard addition with carry propagation in a single-radix positional system.

leetcodemediumstringgreedybit-manipulation
LeetCode 3874 - Valid Subarrays With Exactly One Peak

The problem asks us to count the number of contiguous subarrays of a given integer array nums that contain exactly one peak, where a peak is defined as an element nums[i] that is strictly greater than both its immediate neighbors nums[i-1] and nums[i+1].

leetcodemediumarraymath
LeetCode 3861 - Minimum Capacity Box

The problem presents a straightforward search scenario. You are given an array capacity where each element represents the storage capacity of a box. You are also given an integer itemSize, representing the size of an item you want to store.

leetcodeeasyarray
LeetCode 3859 - Count Subarrays With K Distinct Integers

This problem asks us to count subarrays of a given integer array nums such that each subarray contains exactly k distinct integers, and each distinct integer in the subarray appears at least m times.

leetcodehardarrayhash-tablesliding-windowcounting
LeetCode 3824 - Minimum K to Reduce Array Within Limit

This problem asks us to determine the minimum positive integer k such that, after repeatedly subtracting k from each element of the array nums, the total number of operations needed to reduce every element to non-positive is at most k^2.

leetcodemediumarraybinary-search
LeetCode 3820 - Pythagorean Distance Nodes in a Tree

The problem requires identifying special nodes in a tree based on distances to three distinct target nodes, x, y, and z.

leetcodemediumtreebreadth-first-search
LeetCode 3831 - Median of a Binary Search Tree Level

Exercise 4.3.1.9 asks for a generalization of Algorithm A to add two -place numbers in a mixed-radix system with bases from right to left. Algorithm A in TAOCP §4.3.1 describes standard addition with carry propagation in a single-radix positional system.

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-search-treebinary-tree
CF 1554E - You

We are given a tree with $n$ nodes, which is a connected acyclic graph, and we need to construct sequences by repeatedly erasing nodes.

codeforcescompetitive-programmingdfs-and-similardpmathnumber-theory
LeetCode 3810 - Minimum Operations to Reach Target Array

We are given two arrays, nums and target, of equal length. The array nums represents the current state, while target represents the desired final state. In one operation, we choose a value x. Then we locate every maximal contiguous segment whose current value is exactly x.

leetcodemediumarrayhash-tablegreedy
LeetCode 3814 - Maximum Capacity Within Budget

Exercise 4.3.1.9 asks for a generalization of Algorithm A to add two -place numbers in a mixed-radix system with bases from right to left. Algorithm A in TAOCP §4.3.1 describes standard addition with carry propagation in a single-radix positional system.

leetcodemediumarraytwo-pointersbinary-searchsorting
LeetCode 3809 - Best Reachable Tower

This problem asks us to identify the "best reachable tower" from a given center location within a specified Manhattan distance radius. Each tower has a coordinate (xi, yi) and a quality factor qi.

leetcodemediumarray
LeetCode 3797 - Count Routes to Climb a Rectangular Grid

We are given an n × m grid where each cell is either available ('.') or blocked (''). A route starts from any available cell in the bottom row and must eventually end in the top row. During the route, every visited cell must be available. The movement rules are unusual: 1.

leetcodehardarraydynamic-programmingmatrixprefix-sum
LeetCode 3800 - Minimum Cost to Make Two Binary Strings Equal

Exercise 4.3.1.9 asks for a generalization of Algorithm A to add two -place numbers in a mixed-radix system with bases from right to left. Algorithm A in TAOCP §4.3.1 describes standard addition with carry propagation in a single-radix positional system.

leetcodemediumstringgreedy
LeetCode 3796 - Find Maximum Value in a Constrained Sequence

We are asked to design an algorithm that adds two numbers digit by digit from most significant to least significant, producing each output digit only when it cannot possibly be affected by future carries. Once an output digit is committed, it may never be revised.

leetcodemediumarraygreedy
LeetCode 3798 - Largest Even Number

We are given a string s that contains only the characters '1' and '2'. We are allowed to delete any number of characters while preserving the relative order of the remaining characters. In other words, we may choose any subsequence of the original string.

leetcodeeasystring
LeetCode 3793 - Find Users with High Token Usage

The prompts table records every prompt submitted by a user to an AI system. Each row contains a userid, the prompt text itself, and the number of tokens consumed by that prompt.

leetcodeeasy
CF 1554A - Cherry

We are given an array of positive integers. For every subarray that contains at least two elements, we compute the product of its largest element and its smallest element. The task is to find the maximum such product among all possible subarrays.

codeforcescompetitive-programminggreedy
LeetCode 3787 - Find Diameter Endpoints of a Tree

The problem asks us to identify special nodes in a tree, which are nodes that serve as endpoints of any diameter path. A tree is an acyclic connected graph, and its diameter is defined as the longest simple path between any two nodes.

leetcodemediumtreebreadth-first-searchgraph-theory
LeetCode 3785 - Minimum Swaps to Avoid Forbidden Values

This problem asks us to modify an array nums so that for every index i, the element at nums[i] is not equal to the corresponding element at forbidden[i]. The only allowed operation is swapping any two distinct elements of nums.

leetcodehardarrayhash-tablegreedycounting
LeetCode 3777 - Minimum Deletions to Make Alternating Substring

We are given a mutable binary string consisting only of 'A' and 'B'. There are two kinds of queries: - [1, j] flips the character at position j. If it was 'A', it becomes 'B', and vice versa. This permanently changes the string and affects all future queries.

leetcodehardstringsegment-tree
LeetCode 3783 - Mirror Distance of an Integer

The problem gives us a positive integer n and asks us to compute its mirror distance. The mirror distance is defined as: where reverse(n) is the integer obtained by reversing the decimal digits of n, and |x| denotes the absolute value.

leetcodeeasymath
CF 1555F - Good Graph

We are maintaining an undirected graph that grows edge by edge. Every edge has a binary weight, either 0 or 1. After each insertion request, we must decide whether adding that edge keeps a certain global property valid.

codeforcescompetitive-programmingdata-structuresdsugraphstrees
LeetCode 3776 - Minimum Moves to Balance Circular Array

Exercise 4.3.1.7 asks for the average number of times the algorithm of Exercise 5 finds that a carry propagates through exactly digits of the partial answer, for , under the assumption that both inputs are independent and uniformly distributed integers in .

leetcodemediumarraygreedysorting
LeetCode 3752 - Lexicographically Smallest Negated Permutation that Sums to Target

We are given two values: - n, which determines the numbers 1, 2, ..., n - target, which is the required sum of the final array We must construct an array of length n whose absolute values are exactly the numbers 1 through n, each used once.

leetcodemediumarraymathtwo-pointersgreedysorting
CF 1555C - Coin Rows

We are given a 2-row grid of coins with m columns. Alice and Bob both start at the top-left corner (1,1) and want to reach the bottom-right (2,m) using only moves to the right or down. Alice moves first and collects all coins along her path.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdpimplementation
LeetCode 3747 - Count Distinct Integers After Removing Zeros

The problem asks us to consider all integers from 1 up to a given number n. For each integer, we are required to write down a transformed version of that number in which all zeros are removed. For example, 102 would become 12, and 500 would become 5.

leetcodemediummathdynamic-programming
LeetCode 3740 - Minimum Distance Between Three Equal Elements I

The problem gives us an integer array nums and asks us to find three distinct indices (i, j, k) such that all three positions contain the same value: Such a triple is called a good tuple.

leetcodeeasyarrayhash-table
LeetCode 3735 - Lexicographically Smallest String After Reverse II

The problem is asking us to manipulate a string s of length n in order to produce the lexicographically smallest possible string after exactly one operation.

leetcodehardstringbinary-searchrolling-hashsuffix-arrayhash-function
LeetCode 3732 - Maximum Product of Three Elements After One Replacement

This problem asks us to maximize the product of any three distinct elements in an array, given that we are allowed to replace exactly one element in the array with any integer from -10^5 to 10^5. The input is an integer array nums of length at least 3 and at most 10^5.

leetcodemediumarraymathgreedysorting
LeetCode 3719 - Longest Balanced Subarray I

The problem asks us to find the longest contiguous subarray of an integer array nums such that the number of distinct even numbers in the subarray is equal to the number of distinct odd numbers.

leetcodemediumarrayhash-tabledivide-and-conquersegment-treeprefix-sum
LeetCode 3713 - Longest Balanced Substring I

The problem is asking us to find the length of the longest substring of a given string s where all distinct characters in that substring appear the same number of times.

leetcodemediumhash-tablestringcountingenumeration
LeetCode 3701 - Compute Alternating Sum

This problem asks us to compute the alternating sum of an integer array nums. The alternating sum is calculated by taking the sum of elements at even indices (0, 2, 4, ...) and subtracting the sum of elements at odd indices (1, 3, 5, ...).

leetcodeeasyarraysimulation
LeetCode 3678 - Smallest Absent Positive Greater Than Average

The crash is now purely an input-format mismatch, and it already reveals exactly where the implementation diverges from the actual problem.

leetcodeeasyarrayhash-table
LeetCode 3673 - Find Zombie Sessions

Exercise 4.3.1.7 asks for the average number of times the algorithm of Exercise 5 finds that a carry propagates through exactly digits of the partial answer, for , under the assumption that both inputs are independent and uniformly distributed integers in .

leetcodehard
LeetCode 3670 - Maximum Product of Two Integers With No Common Bits

The problem asks us to find the maximum product of two distinct elements in an array of integers, under the constraint that their binary representations do not share any set bits.

leetcodemediumarraydynamic-programmingbit-manipulation
LeetCode 3669 - Balanced K-Factor Decomposition

The problem asks us to split a positive integer n into exactly k positive integers such that the product of these integers equals n. Among all possible splits, we are required to find one in which the maximum difference between any two numbers is minimized.

leetcodemediummathbacktrackingnumber-theory
LeetCode 3659 - Partition Array Into K-Distinct Groups

We are given an integer array nums and an integer k. The goal is to determine whether all elements of the array can be partitioned into one or more groups such that every group satisfies two conditions: 1. Each group contains exactly k elements. 2.

leetcodemediumarrayhash-tablecounting
LeetCode 3649 - Number of Perfect Pairs

This problem asks us to count the number of perfect pairs in an integer array nums. A pair (i, j) is perfect if i < j and the elements at these indices satisfy two conditions: the minimum of |a - b| and |a + b| is less than or equal to the smaller absolute value of the two…

leetcodemediumarraymathtwo-pointerssorting
LeetCode 3637 - Trionic Array I

We interpret the task as follows. Two nonnegative integers are given in radix , each represented as a sequence of digits. The digits are not processed in the standard right-to-left carry propagation.

leetcodeeasyarray
LeetCode 3644 - Maximum K to Sort a Permutation

The problem provides a permutation array nums of length n, meaning it contains each integer from 0 to n-1 exactly once, in some arbitrary order.

leetcodemediumarraybit-manipulation
LeetCode 3628 - Maximum Number of Subsequences After One Inserting

The solution partially addresses the exercise, but it does not fully satisfy what was asked. The exercise is not asking for modern algorithms that resemble the work of Sun Tsï, al-Khwārizmī, al-Uqlidisī, Fibonacci, and Recorde.

leetcodemediumstringdynamic-programminggreedyprefix-sum
LeetCode 3624 - Number of Integers With Popcount-Depth Equal to K II

The problem asks us to efficiently handle queries on an array nums involving a special property called the popcount-depth.

leetcodehardarraydivide-and-conquerbinary-indexed-treesegment-tree
LeetCode 3627 - Maximum Median Sum of Subsequences of Size 3

We are given an array nums whose length is always divisible by 3. The array must be emptied by repeatedly selecting exactly three elements. For each selected triple, we compute its median, add that median to our answer, and remove all three elements from the array.

leetcodemediumarraymathgreedysortinggame-theory
LeetCode 3629 - Minimum Jumps to Reach End via Prime Teleportation

This problem is essentially about navigating an array using two types of moves: adjacent steps and prime-based teleportation. You start at the first index and want to reach the last index in the minimum number of moves.

leetcodemediumarrayhash-tablemathbreadth-first-searchnumber-theory
LeetCode 3603 - Minimum Cost Path with Alternating Directions II

No. The proposed solution does not answer Exercise 4.3.1.1 at all. Exercise 4.3.1.1 asks the reader to study the early history of classical arithmetic algorithms by consulting historical sources (e.g.

leetcodemediumarraydynamic-programmingmatrix
LeetCode 3623 - Count Number of Trapezoids I

The problem asks us to count the number of horizontal trapezoids that can be formed from a set of points in 2D Cartesian space.

leetcodemediumarrayhash-tablemathgeometry
LeetCode 3613 - Minimize Maximum Component Cost

The problem asks us to minimize the maximum cost among components in a connected undirected graph after removing edges. Each edge has a weight, and the cost of a connected component is the largest weight of any edge in that component.

leetcodemediumbinary-searchunion-findgraph-theorysorting
LeetCode 3608 - Minimum Time for K Connected Components

We are given an undirected graph with n vertices and a list of edges. Each edge has a removal time timei. The graph evolves over time. At time t, every edge whose removal time satisfies timei <= t has already been removed. All remaining edges are those with timei t.

leetcodemediumbinary-searchunion-findgraph-theorysorting
CF 1558B - Up the Strip

We are given a token placed at position $n$ on a vertical line of cells labeled from $1$ at the top to $n$ at the bottom. The goal is to count how many distinct sequences of moves can bring the token from $n$ down to $1$. From a position $x 1$, two types of moves are allowed.

codeforcescompetitive-programmingbrute-forcedpmathnumber-theorytwo-pointers
LeetCode 3601 - Find Drivers with Improved Fuel Efficiency

This problem asks us to analyze fuel efficiency trends for drivers across two different periods of the year. We are given two tables: - drivers, which stores each driver's identifier and name.

leetcodemediumdatabase
LeetCode 3602 - Hexadecimal and Hexatrigesimal Conversion

The problem gives us a single integer n and asks us to construct a string from two different number system conversions.

leetcodeeasymathstring
LeetCode 3584 - Maximum Product of First and Last Elements of a Subsequence

Program B is designed to perform a sequence of numerical calculations using the X-register of a hypothetical or HP-style RPN calculator. In such machines, the X-register holds the current number on the stack.

leetcodemediumarraytwo-pointers
LeetCode 3598 - Longest Common Prefix Between Adjacent Strings After Removals

We are given a token placed at position on a vertical line of cells labeled from at the top to at the bottom. The goal is to count how many distinct sequences of moves can bring the token from down to . From a position , two types of moves are allowed.

leetcodemediumarraystring
LeetCode 3587 - Minimum Adjacent Swaps to Alternate Parity

The problem requires transforming a given array of distinct integers into an arrangement where the parity of adjacent elements alternates - that is, an even number must always be next to an odd number, and vice versa.

leetcodemediumarraygreedy
LeetCode 3583 - Count Special Triplets

This problem asks us to count the number of special triplets in an integer array nums. A special triplet (i, j, k) must satisfy three conditions: the indices are strictly increasing 0 <= i < j < k < n, nums[i] is exactly double nums[j], and nums[k] is also exactly double nums[j].

leetcodemediumarrayhash-tablecounting
LeetCode 3562 - Maximum Profit from Trading Stocks with Discounts

This problem asks us to maximize profit from buying and selling stocks under a hierarchical discount structure. Each employee can buy a stock today at a present price and sell it tomorrow at a future price.

leetcodehardarraydynamic-programmingtreedepth-first-search
CF 1559A - Mocha and Math

We are given an array of integers and allowed to perform a repeated operation: choose any contiguous subarray and replace each element in it with the bitwise AND of itself and its symmetric counterpart relative to the interval.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsmath
LeetCode 3569 - Maximize Count of Distinct Primes After Split

Here is a complete, detailed technical solution guide following your exact formatting rules. This problem asks us to handle dynamic array updates and, after each update, find the maximum sum of distinct prime counts across any valid split of the array.

leetcodehardarraymathsegment-treenumber-theory
LeetCode 3551 - Minimum Swaps to Sort by Digit Sum

The problem asks us to sort an array of distinct positive integers not by their natural numeric value, but by the sum of their digits. If two numbers share the same digit sum, the smaller number must come first.

leetcodemediumarrayhash-tablesorting
LeetCode 3568 - Minimum Moves to Clean the Classroom

We are given a grid representing a classroom. A student starts at the cell marked 'S' and must collect every litter cell marked 'L'. Movement is allowed only in the four cardinal directions, and moving one cell costs exactly one unit of energy.

leetcodemediumarrayhash-tablebit-manipulationbreadth-first-searchmatrix
LeetCode 3564 - Seasonal Sales Analysis

This problem asks us to analyze sales data and determine the most popular product category for each season based on the total quantity sold.

leetcodemediumdatabase