brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 1530D - Secret Santa

We are asked to construct a permutation-like assignment for a group of people. Each person must give a gift to exactly one other person, and no one is allowed to give a gift to themselves.

codeforcescompetitive-programmingconstructive-algorithmsflowsgraphsgreedymath
CF 1530B - Putting Plates

We are asked to maximize the number of plates on a rectangular table, represented as an $h times w$ grid. Plates can only be placed along the perimeter, which includes the first row, last row, first column, and last column.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1530A - Binary Decimal

The problem asks us to break a positive integer $n$ into a sum of numbers whose decimal digits are only 0 or 1. These numbers are called binary decimals, like 1, 10, 11, 101, 1000. The goal is to determine the smallest number of such binary decimals that sum up to $n$.

codeforcescompetitive-programminggreedymath
CF 1530C - Pursuit

We have a contest with multiple stages, each stage giving between 0 and 100 points. You and Ilya have already completed n stages, and we know the scores for both of you.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedysortings
CF 1531E2 - Сортировка слиянием

We are given a string consisting of 0s and 1s, which represents the sequence of decisions made during the merge steps of a merge sort on some permutation of integers from 1 to n.

codeforcescompetitive-programming*specialbrute-force
CF 1531D - Редактируем Зингер | color

We have a chronological list of bot messages. The bot keeps two pieces of state. The first is whether color changes are currently locked. The second is the current dome color, one of seven rainbow colors. Initially the dome is blue and color changes are unlocked.

codeforcescompetitive-programming*special
CF 1531C - Симметричный амфитеатр

We are asked to design a side-view schematic of an amphitheater built from exactly n identical squares. The layout must form a staircase structure, meaning a sequence of towers with heights that do not increase from left to right.

codeforcescompetitive-programming*specialconstructive-algorithmsdp
CF 1531E1 - Сортировка слиянием

The merge sort code in the statement does not only sort an array, it also records the sequence of decisions taken during every comparison while merging two sorted halves.

codeforcescompetitive-programming*special
CF 1531B1 - Мониторинг

We are given a collection of monitors, each with a width and a height. We want to count how many unordered pairs of distinct monitors can be rotated so that their heights match. Rotating a monitor swaps its width and height.

codeforcescompetitive-programming*special
CF 1531A - Зингер | color

We need to simulate the behavior of a chatbot that controls the illumination color of the Singer House dome. Initially, the dome is colored blue, and color changes are allowed. The bot receives a sequence of messages.

codeforcescompetitive-programming*specialimplementation
CF 1531B2 - Мониторинг

We are given a set of monitors, each with a width and height, and we can rotate any monitor by 90 degrees. Our goal is to count the number of distinct unordered pairs of monitors such that after potentially rotating either or both, their heights match.

codeforcescompetitive-programming*special
Kvant Math Problem 1101

Let $ABC$ be an isosceles triangle with $AB=AC=s$ and $BC=b$.

kvantmathematicsolympiad
CF 1532D - Teams Forming

We are given an even number of students, each with a programming skill level. The goal is to form exactly $n/2$ teams, each containing two students. A team is valid only if both students have the same skill level.

codeforcescompetitive-programming*specialsortings
Kvant Math Problem 1076

Let $ABC$ be an acute triangle.

kvantmathematicsolympiad
CF 1533J - Pawns

We are given an infinite chessboard with black pawns placed at certain integer coordinates. Our goal is to capture all black pawns using as few white pawns as possible.

codeforcescompetitive-programming*special
CF 1533F - Binary String Partition

We are given a binary string. For a fixed value of $k$, a substring is considered valid if at least one of the two character counts is small: either it contains at most $k$ zeroes or at most $k$ ones.

codeforcescompetitive-programming*specialbinary-searchgreedy
CF 1533E - Chess Team Forming

We are tasked with forming a chess team by adding one final player to Polycarp's existing roster of $n$ members. Each player's strength is an integer, and the opposing team already has $n+1$ members.

codeforcescompetitive-programming*specialbinary-searchdata-structuresgreedy
Kvant Math Problem 1043

A partition of $\mathbb{Z}$ into three subsets is encoded by a function $f:\mathbb{Z}\to\mathbb{Z}_3$.

kvantmathematicsolympiad
CF 1534G - A New Beginning

The claimed output 10 for "0?10" is actually impossible. There are only 10 total substrings of a length-4 string, and two of them are not beautiful: - "0?10" cannot be made alternating. - "?10" cannot be made alternating. So the correct answer is 8.

codeforcescompetitive-programmingdata-structuresdpgeometrysortings
Kvant Math Problem 1029

Let the arithmetic progression be

kvantmathematicsolympiad
IMO 1972 Problem 5

The correction cannot rely on supremum arguments or derived proportionality identities because those depend on unjustified global structure of $f$ and $g$.

imomathematicsolympiad
CF 1534H - Lost Nodes

Consider a closed container of fixed volume $V$ containing an ideal gas whose bulk temperature is $T1$. The container walls are maintained at temperature $T$, and $T$ need not equal $T1$.

codeforcescompetitive-programmingconstructive-algorithmsdpgraphsinteractivesortingstrees
CF 1534F2 - Falling Sand (Hard Version)

We are given a grid representing a vertical board filled with sand blocks. Each cell either contains a block or is empty. There are also target requirements per column: for every column, we want at least a certain number of sand blocks to end up in a counter at the bottom.

codeforcescompetitive-programmingdfs-and-similardpgraphsgreedy
CF 1534B - Histogram Ugliness

We are given a histogram represented as an array of integers, where each integer is the height of a vertical bar. Little Dormi can decrease the height of any bar by one repeatedly, and each such decrease counts as an operation.

codeforcescompetitive-programminggreedyimplementationmath
CF 1534D - Lost Tree

We are asked to reconstruct an unweighted tree given a limited interactive query mechanism. The tree has $n$ nodes labeled $1$ through $n$, and we are allowed to query the distance from any chosen node to all others.

codeforcescompetitive-programmingconstructive-algorithmsinteractivetrees
CF 1534F1 - Falling Sand (Easy Version)

We are given a grid of n rows and m columns where each cell either contains a sand block () or is empty (.). Alongside the grid, we are given an array a of length m. In this easy version of the problem, each a[i] exactly equals the number of sand blocks in column i.

codeforcescompetitive-programmingdfs-and-similargraphsgreedy
CF 1534E - Lost Array

We are given a hidden array of length n. We cannot see its elements directly, but we are allowed to ask queries. Each query chooses exactly k distinct positions, and the system returns the XOR of the values at those positions.

codeforcescompetitive-programminggraphsgreedyinteractiveshortest-paths
CF 1534C - Little Alawn's Puzzle

We are given a 2 by n grid where each row is a permutation of numbers from 1 to n. So every number appears exactly once in each row, and every column contains two distinct values. The only operation allowed is swapping the two values inside any column.

codeforcescompetitive-programmingcombinatoricsdpdsugraphsmath
CF 1534A - Colour the Flag

The claimed output 10 for "0?10" is actually impossible. There are only 10 total substrings of a length-4 string, and two of them are not beautiful: - "0?10" cannot be made alternating. - "?10" cannot be made alternating. So the correct answer is 8.

codeforcescompetitive-programmingbrute-forceimplementation
CF 1535C - Unstable String

We are given a string containing '0', '1', and '?'. A substring is considered beautiful if we can replace every '?' independently with either 0 or 1 so that the resulting substring becomes an alternating binary string. In other words, neighboring characters must always differ.

codeforcescompetitive-programmingbinary-searchdpgreedyimplementationstringstwo-pointers
CF 1535F - String Distance

We are given a collection of strings of equal length, and our task is to quantify how "sortable into each other" they are using a specific operation. This operation allows us to take any contiguous substring in one string and sort its characters in ascending order.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structureshashingimplementationstrings
CF 1535E - Gold Transfer

I see what is happening. The actual output is empty. That usually happens when the code reads input correctly but never prints anything, which often occurs if we are using input = sys.stdin.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedyinteractivetrees
CF 1535A - Fair Playoff

We have a mini playoff tournament with exactly four players. The first two face off, the last two face off, and the winners meet in the final. Each player has a unique skill value, and in any match the higher-skilled player always wins.

codeforcescompetitive-programmingbrute-forceimplementation
CF 1535D - Playoff Tournament

The proposed solution does not answer the exercise at all. Exercise 4.3.2.7 asks for a derivation of an alternative form of equation (24) in the Chinese remainder conversion algorithm, followed by a discussion of the computational advantages and disadvantages of storing the…

codeforcescompetitive-programmingdata-structuresdfs-and-similardpimplementationtrees
CF 1535B - Array Reodering

We are given an array of integers and may permute it however we like. After choosing an ordering, a pair of positions $(i,j)$ with $i<j$ is called good if $$gcd(ai, 2aj) 1.$$ The task is to maximize the number of good pairs. The input contains multiple test cases.

codeforcescompetitive-programmingbrute-forcegreedymathnumber-theorysortings
CF 1536F - Omkar and Akmar

We are asked to count all possible distinct games played on a circular board with $n$ cells, where two players take turns placing letters A or B. Akmar moves first. A letter cannot be placed adjacent to a cell that already contains the same letter.

codeforcescompetitive-programmingchinese-remainder-theoremcombinatoricsconstructive-algorithmsfftgamesgeometrymathmeet-in-the-middlestring-suffix-structures
CF 1537B - Bad Boy

We are asked to place two yo-yos in a rectangular room to maximize the total Manhattan distance Anton must travel to pick them both up and return to his starting position. The room is an $n times m$ grid, and Anton starts at cell $(i, j)$.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1537F - Figure Fixing

We are given a connected undirected graph where each node has an initial value and a target value. We can pick any edge and add the same integer to both endpoints.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardsugraphsgreedymath
CF 1537E2 - Erase and Extend (Hard Version)

Codeforces 1537E2: Erase and Extend (Hard Version)

codeforcescompetitive-programmingbinary-searchdata-structuresgreedyhashingstring-suffix-structuresstringstwo-pointers
CF 1537E1 - Erase and Extend (Easy Version)

We are given a string s of length n and a target length k. Our goal is to construct a string of length exactly k by performing two operations any number of times: removing the last character of the current string, or duplicating the string by concatenating it with itself.

codeforcescompetitive-programmingbinary-searchbrute-forcedpgreedyhashingimplementationstring-suffix-structuresstringstwo-pointers
CF 1537C - Challenging Cliffs

We are given a multiset of mountain heights and must arrange them into a sequence. The optimization happens in two layers. First, among all possible permutations, we want the first and last heights to be as close as possible.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationmath
CF 1537D - Deleting Divisors

We start with a positive integer $n$. Two players alternate turns, with Alice moving first. On each turn, the current player chooses a proper divisor of the current number, meaning a divisor that is neither $1$ nor the number itself, and subtracts it from the number.

codeforcescompetitive-programminggamesmathnumber-theory
CF 1537A - Arithmetic Array

We are given an integer array, and our task is to make its arithmetic mean equal to one by appending non-negative integers. Each test case presents an array of arbitrary integers, both positive and negative, and asks for the minimal number of additions needed.

codeforcescompetitive-programminggreedymath
CF 1538G - Gift Set

We have two piles of candies. One pile contains x red candies and the other contains y blue candies. Each gift set must use exactly a + b candies. There are two possible compositions: - a red and b blue - b red and a blue The two types are symmetric.

codeforcescompetitive-programmingbinary-searchgreedymathternary-search
CF 1538C - Number of Pairs

We are given an array of integers and a range defined by two values, l and r. The task is to count all pairs of distinct indices (i, j) such that the sum of the elements at these indices lies within the given range, including the boundaries.

codeforcescompetitive-programmingbinary-searchdata-structuresmathtwo-pointers
CF 1538B - Friends and Candies

We are given an array of integers representing how many candies each person initially holds. In a single operation, we are allowed to pick some subset of people, take all candies from them, and then freely redistribute those candies across everyone.

codeforcescompetitive-programminggreedymath
CF 1539F - Strange Array

The solution attempts to prove the lower bound on the true remainder when the trial quotient $hat q$ underestimates the true quotient $q$ by 1. It correctly identifies that $hat q = q-1$ under the hypotheses and expresses the true remainder as $r = hat r - v$.

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 1539E - Game with Cards

Represent each integer in base $b$ as a doubly linked list of digits $$(v{n-1}, v{n-2}, dots, v0),$$ where each node contains one digit $vi in {0, dots, b-1}$, together with pointers $$text{left}(i), text{right}(i)$$ to adjacent digits.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresdpgreedyimplementation
CF 1539C - Stable Groups

We are given the skill levels of students. A group is considered stable if, after sorting the students inside that group, every adjacent pair differs by at most x.

codeforcescompetitive-programminggreedysortings
CF 1539B - Love Song

We are given a lowercase string representing the song and many queries on contiguous substrings of that string. Each letter contributes a value equal to its position in the alphabet. For example, a = 1, b = 2, c = 3, and so on.

codeforcescompetitive-programmingdpimplementationstrings
CF 1539D - PriceFixed

We are asked to determine the minimal total cost for Lena to buy a set of products where each product has a required quantity and a threshold for a discount.

codeforcescompetitive-programmingbinary-searchgreedyimplementationsortingstwo-pointers
CF 1539A - Contest Start

Represent each integer in base $b$ as a doubly linked list of digits $$(v{n-1}, v{n-2}, dots, v0),$$ where each node contains one digit $vi in {0, dots, b-1}$, together with pointers $$text{left}(i), text{right}(i)$$ to adjacent digits.

codeforcescompetitive-programmingcombinatoricsgeometrygreedymath
CF 1540D - Inverse Inversions

The array $b$ is not arbitrary. For every position $i$, $bi$ tells us how many earlier elements of the permutation are larger than $pi$.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structures
CF 1540E - Tasty Dishes

We are given a small directed system of chefs, where each chef holds a value. The structure is acyclic in the sense that chef $i$ can only interact with chefs of higher index. This allows information to flow only from right to left.

codeforcescompetitive-programmingmathmatrices
CF 1540C1 - Converging Array (Easy Version)

The operation acts on a neighboring pair. Let $$di=a{i+1}-ai.$$ If $dige bi$, the operation changes nothing. If $di<bi$, both values are replaced by numbers with the same sum and with difference exactly $bi$.

codeforcescompetitive-programmingdpmath
CF 1540B - Tree Array

We are asked to calculate the expected number of inversions in a random process of marking nodes in a tree. The tree has n nodes, and the marking process begins with a uniformly random initial node.

codeforcescompetitive-programmingbrute-forcecombinatoricsdpgraphsmathprobabilitiestrees
CF 1540A - Great Graphs

We are given a farm with $n$ pastures and one-way roads between them. Each road has a travel time, which can be negative. Farmer John remembers only the shortest travel times from pasture 1 to every other pasture.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedyshortest-pathssortings
CF 1541A - Pretty Permutations

We are asked to reorder a sequence of cats standing in a line so that no cat remains in its original position, while also minimizing the total distance each cat moves. The input consists of several test cases, each specifying a single integer $n$ - the number of cats.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 1541B - Pleasant Pairs

We are given several test cases, each containing an array of distinct integers indexed from 1. The task is to count how many index pairs $(i, j)$ with $i < j$ satisfy a very specific relationship: the product of the values stored at those positions equals the sum of the…

codeforcescompetitive-programmingbrute-forceimplementationmathnumber-theory
CF 1542B - Plus and Multiply

We start from the number $1$. From any number already in the set, we may perform either of two operations: multiply by $a$, or add $b$. After applying these operations any number of times in any order, we obtain an infinite set of reachable values.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 1542E2 - Abnormal Permutation Pairs (hard version)

The solution does not answer the stated problem correctly. The expression to be bounded is $$leftlfloor frac{b}{2} rightrfloor le leftlfloor frac{b}{v+1} rightrfloor cdot frac{b}{v+1} le b,$$ but the argument does not correctly establish the lower bound.

codeforcescompetitive-programmingcombinatoricsdpfftmath
CF 1545F - AquaMoon and Potatoes

We are given three integer arrays a, b, c, each of length n. Array a represents a dynamic sequence that can be updated. Arrays b and c are fixed mappings that define relationships: b[x] gives a value associated with x from a, and c[x] gives another value associated with an index.

codeforcescompetitive-programmingbrute-forcedata-structuresdp
CF 1545D - AquaMoon and Wrong Coordinate

Codeforces 1545D: AquaMoon and Wrong Coordinate

codeforcescompetitive-programmingconstructive-algorithmsinteractivemath
CF 1545A - AquaMoon and Strange Sort

We are given a row of friends, each wearing a T-shirt with a number. Initially, all friends are facing right. AquaMoon can swap any two adjacent friends, and whenever she does, both friends flip their facing direction.

codeforcescompetitive-programmingsortings
CF 1547F - Array Stabilization (GCD version)

We are given a circular array of positive integers. In each step, we replace every element with the greatest common divisor of itself and its right neighbor, wrapping around at the end.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdivide-and-conquernumber-theorytwo-pointers
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