brain

tamnd's digital brain — notes, problems, research

41650 notes

LeetCode 3933 - Largest Local Values in a Matrix II

The problem asks us to find local maximums in a 2D matrix according to a specialized neighborhood rule. Each cell in the matrix has a value x.

leetcodemediumarraymatrixprefix-sum
CF 1548B - Integers Have Friends

We are given a list of distinct positive integers, and we want to identify the largest contiguous subarray where all elements are congruent modulo some integer greater than or equal to 2.

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquermathnumber-theorytwo-pointers
LeetCode 3926 - Count Valid Word Occurrences

The problem asks us to count occurrences of specific words in a string that is formed by concatenating an array of smaller string "chunks".

leetcodemediumarrayhash-tablestringcounting
LeetCode 3891 - Minimum Increase to Maximize Special Indices

This problem asks us to modify an integer array to create as many special indices as possible, where a special index i is one where nums[i] nums[i-1] and nums[i] nums[i+1].

leetcodemediumarraydynamic-programminggreedyprefix-sum
LeetCode 3843 - First Element with Unique Frequency

The proposed solution does not answer the question that Exercise 4.3.1.17 asks. The exercise is specific: given that and , one must show that the quotient digit in the division step satisfies or .

leetcodemediumarrayhash-tablecounting
LeetCode 3687 - Library Late Fee Calculator

The problem asks us to calculate the total late fee for a library based on how many days each book was returned late. You are given an integer array daysLate, where each element daysLate[i] represents the number of days the i-th book was returned past its due date.

leetcodeeasyarraysimulation
LeetCode 3672 - Sum of Weighted Modes in Subarrays

The problem asks us to calculate the sum of weighted modes for all subarrays of length k in a given array nums. Each subarray is contiguous and has exactly k elements. For a subarray, the mode is the element that occurs most frequently.

leetcodemediumarrayhash-tablesliding-windowcountingordered-set
Kvant Physics Problem 471

The system consists of a thermally insulated cavity of negligible volume compared to the connected vessels, linked via small identical openings to two large volumes of gaseous helium.

kvantphysics
LeetCode 3753 - Total Waviness of Numbers in Range II

The problem asks us to compute a cumulative score over all integers in an inclusive range [num1, num2], where each individual number has a score called waviness.

leetcodehardmathdynamic-programming
LeetCode 3761 - Minimum Absolute Distance Between Mirror Pairs

The proposed solution does not answer the question that Exercise 4.3.1.17 asks. The exercise is specific: given that and , one must show that the quotient digit in the division step satisfies or .

leetcodemediumarrayhash-tablemath
LeetCode 3666 - Minimum Operations to Equalize Binary String

The problem asks us to transform a binary string s consisting of characters '0' and '1' into a string where all characters are '1'. The allowed operation is flipping exactly k different indices in one move, turning '0' to '1' and '1' to '0'.

leetcodehardmathstringbreadth-first-searchunion-findordered-set
LeetCode 3656 - Determine if a Simple Graph Exists

The proposed solution explains in detail how Algorithm S computes subtraction in radix and how the complement-based correction works when a final borrow occurs.

leetcodemediumarraybinary-searchgraph-theorysortingprefix-sum
LeetCode 3650 - Minimum Cost Path with Edge Reversals

We are given a directed weighted graph with n nodes and a list of directed edges. Each edge u → v has a traversal cost w. Normally, we may travel only along the original directed edges and pay the edge weight. However, every node has a special one-time switch.

leetcodemediumgraph-theoryheap-(priority-queue)shortest-path
CF 1550B - Maximum Cost Deletion

We are given a binary string and repeatedly remove substrings that consist of only one character type. Every deletion of a substring of length l gives a l + b points. The string shrinks after each operation because the remaining parts are concatenated together.

codeforcescompetitive-programminggreedymath
LeetCode 3645 - Maximum Total from Optimal Activation Order

This problem involves determining the maximum total value achievable by activating elements in an array under a set of constraints. We are given two arrays, value and limit, both of length n.

leetcodemediumarraytwo-pointersgreedysortingheap-(priority-queue)
LeetCode 3631 - Sort Threats by Severity and Exploitability

The problem gives a list of threats, where each threat is represented as a triplet [IDi, sevi, expi]. Each threat has a unique identifier, a severity value, and an exploitability value.

leetcodemediumarraysorting
LeetCode 3581 - Count Odd Letters from Number

Algorithm S performs digit-by-digit subtraction in radix without requiring knowledge of whether . It produces digits and a final borrow , where occurs if and only if .

leetcodeeasyhash-tablestringsimulationcounting
LeetCode 3575 - Maximum Good Subtree Score

We are given a rooted tree with n nodes. Node 0 is the root, and the tree structure is described by the parent array par, where par[i] is the parent of node i. Each node contains an integer value vals[i].

leetcodehardarraydynamic-programmingbit-manipulationtreedepth-first-searchbitmask
LeetCode 3576 - Transform Array to All Equal Elements

The problem asks whether it is possible to transform an array of integers containing only 1 and -1 into an array where all elements are equal by performing at most k operations.

leetcodemediumarraygreedy
LeetCode 3473 - Sum of K Subarrays With Length at Least M

The problem gives an integer array nums, together with two integers k and m. We must choose exactly k non-overlapping subarrays, and every chosen subarray must have length at least m. Among all valid choices, we want the maximum possible total sum.

leetcodemediumarraydynamic-programmingprefix-sum
LeetCode 3485 - Longest Common Prefix of K Strings After Removal

This problem asks us to calculate the longest common prefix (LCP) among any k strings from a list of strings, after removing each string in turn. Specifically, for each index i, we remove words[i] from the array, then find the longest prefix shared by any k remaining strings.

leetcodehardarraystringtrie
LeetCode 3455 - Shortest Matching Substring

The problem asks us to find the length of the shortest substring in a given string s that matches a pattern string p, where the pattern contains exactly two wildcard '' characters.

leetcodehardtwo-pointersstringbinary-searchstring-matching
LeetCode 3410 - Maximize Subarray Sum After Removing All Occurrences of One Element

Algorithm S performs digit-by-digit subtraction in radix without requiring knowledge of whether . It produces digits and a final borrow , where occurs if and only if .

leetcodehardarraydynamic-programmingsegment-tree
Kvant Physics Problem 324

The optical element is a thin converging lens with focal length $f = 50\ \text{cm}$ and diameter $d = 5\ \text{cm}$.

kvantphysics
LeetCode 3943 - Number of Pairs After Increment

The problem gives two integer arrays nums1 and nums2 and a list of queries. Each query is either an increment operation on a subarray of nums2 or a pair-counting operation that asks for the number of pairs (j, k) such that nums1[j] + nums2[k] equals a target value tot.

leetcodehard
LeetCode 3942 - Minimum Operations to Sort a Permutation

The problem gives an array nums that is guaranteed to be a permutation of integers from 0 to n - 1. The goal is to transform this array into the sorted order [0, 1, 2, ..., n - 1] using only two allowed operations: a left rotation by one position and a full reversal of the array.

leetcodemedium
LeetCode 3940 - Limit Occurrences in Sorted Array

This problem gives us a sorted integer array nums and an integer k. Our goal is to produce a result where every distinct value appears no more than k times. Because the array is already sorted in non-decreasing order, all occurrences of the same value appear consecutively.

leetcodeeasy
LeetCode 3941 - Password Strength

The problem requires calculating the strength of a password based on its distinct characters. Each character type contributes differently to the strength: lowercase letters add 1 point, uppercase letters add 2 points, digits add 3 points, and special characters from "!

leetcodemedium
LeetCode 3937 - Minimum Operations to Make Array Modulo Alternating I

The problem asks us to transform an array of integers, nums, into a modulo alternating array with the minimum number of operations, where each operation is either incrementing or decrementing an element by 1.

leetcodemedium
LeetCode 3938 - Maximum Path Intersection Sum in a Grid

Here’s a fully detailed technical solution guide for LeetCode 3938, following your formatting and content requirements. The problem provides an m x n integer grid and two players with distinct movement constraints.

leetcodemedium
LeetCode 3939 - Count Non Adjacent Subsets in a Rooted Tree

We are given a rooted tree with n nodes. The tree is represented by the parent array, where parent[i] tells us the parent of node i. Node 0 is always the root because parent[0] = -1. Each node also has a value stored in nums[i].

leetcodehard
LeetCode 3936 - Minimum Swaps to Move Zeros to End

The problem gives us an integer array nums containing values between 0 and 100. We may perform an operation where we choose any two distinct indices and swap their values. Our goal is to move all zeros to the end of the array while using the minimum possible number of swaps.

leetcodeeasy
LeetCode 3934 - Smallest Unique Subarray

The problem asks us to find the smallest possible length of a contiguous subarray such that there exists at least one subarray of that length that appears exactly once in the entire array.

leetcodehardarrayhash-tablebinary-searchrolling-hashsuffix-arrayhash-function
CF 1551A - Polycarp and Coins

Polycarp needs to pay exactly n burles using only coins worth 1 burle and 2 burles. Let c1 be the number of 1-burle coins and c2 be the number of 2-burle coins.

codeforcescompetitive-programminggreedymath
LeetCode 3932 - Count K-th Roots in a Range

This problem asks us to count how many integers in a given range [l, r] are perfect kth powers, meaning each integer can be expressed as x^k for some integer x.

leetcodemediummathbinary-search
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