brain

tamnd's digital brain — notes, problems, research

41835 notes

LeetCode 3730 - Maximum Calories Burnt from Jumps

The problem asks us to determine the maximum total calories that can be burned while visiting every block exactly once in an arbitrary order. We are given an integer array heights, where heights[i] represents the height of a block.

leetcodemediumarraytwo-pointersgreedysorting
LeetCode 3821 - Find Nth Smallest Integer With K One Bits

This problem asks us to find the nth smallest positive integer whose binary representation contains exactly k ones. In other words, we are working with numbers that, when written in binary, have a specific number of bits set to 1.

leetcodehardmathbit-manipulationcombinatorics
LeetCode 3728 - Stable Subarrays With Equal Boundary and Interior Sum

The problem asks us to count stable subarrays in an integer array capacity. A subarray capacity[l..r] is stable if it satisfies two conditions: its length is at least 3, and the first and last elements are each equal to the sum of the elements strictly between them.

leetcodemediumarrayhash-tableprefix-sum
LeetCode 3819 - Rotate Non Negative Elements

The problem asks us to rotate only the non-negative elements of an integer array nums to the left by k positions in a cyclic manner, while leaving all negative elements fixed in their original positions.

leetcodemediumarraysimulation
LeetCode 3725 - Count Ways to Choose Coprime Integers from Rows

The problem asks us to determine how many ways we can choose exactly one number from each row of a given m x n matrix such that the greatest common divisor (GCD) of all chosen numbers is 1.

leetcodehardarraymathdynamic-programmingmatrixcombinatoricsnumber-theory
LeetCode 3817 - Good Indices in a Digit String

We are given a string s consisting only of decimal digits. The string length is n, and indices are zero-based. For every index i, we need to determine whether i is a good index.

leetcodemediummathstring
LeetCode 3818 - Minimum Prefix Removal to Make Array Strictly Increasing

The problem asks us to process an integer array nums and determine the minimum length of a prefix that we can remove so that the remaining array becomes strictly increasing.

leetcodemediumarray
LeetCode 3724 - Minimum Operations to Transform Array

This problem asks us to transform an array nums1 of length n into another array nums2 of length n + 1 using the minimum number of operations. The allowed operations are increasing or decreasing any element of nums1 by 1, or appending any element of nums1 to the end of the array.

leetcodemediumarraygreedy
LeetCode 3816 - Lexicographically Smallest String After Deleting Duplicate Characters

We are given a string s consisting only of lowercase English letters. The allowed operation is very specific: if a character currently appears at least twice in the string, we may delete exactly one occurrence of that character.

leetcodehardhash-tablestringstackgreedymonotonic-stack
LeetCode 3722 - Lexicographically Smallest String After Reverse

The problem asks us to find the lexicographically smallest string after performing exactly one reverse operation on a contiguous prefix or suffix of a given string s. The string consists only of lowercase English letters and can have a length up to 1000 characters.

leetcodemediumtwo-pointersbinary-searchenumeration
LeetCode 3815 - Design Auction System

This problem asks us to design a real time auction system that supports inserting, updating, removing, and querying bids efficiently. Each bid is uniquely identified by the pair (userId, itemId). A user may have at most one active bid for a particular item.

leetcodemediumhash-tabledesignheap-(priority-queue)ordered-set
LeetCode 3721 - Longest Balanced Subarray II

The problem requires us to find the length of the longest subarray in an integer array nums where the count of distinct even numbers equals the count of distinct odd numbers.

leetcodehardarrayhash-tabledivide-and-conquersegment-treeprefix-sum
LeetCode 3813 - Vowel-Consonant Score

The problem asks us to compute a score for a given string s. The string may contain lowercase English letters, spaces, and digits. We need to count two quantities: - v, the number of vowels in the string. - c, the number of consonants in the string.

leetcodeeasystringsimulation
LeetCode 3720 - Lexicographically Smallest Permutation Greater Than Target

Before I write the full guide, I want to verify one important detail: LeetCode 3720 appears to be a very recent problem, and the exact intended optimal approach depends on the precise judge behavior and hidden constraints.

leetcodemediumhash-tablestringgreedycountingenumeration
LeetCode 3717 - Minimum Operations to Make the Array Beautiful

Here is the complete, detailed technical solution guide for LeetCode 3717 - Minimum Operations to Make the Array Beautiful following your exact formatting rules. The problem asks us to transform an integer array nums into a beautiful array.

leetcodemediumarraydynamic-programming
LeetCode 3812 - Minimum Edge Toggles on a Tree

We are given a tree with n nodes and n - 1 edges. Every node has a binary color represented by the strings start and target. An operation consists of selecting an edge and toggling both of its endpoints.

leetcodehardtreedepth-first-searchgraph-theorytopological-sortsorting
LeetCode 3714 - Longest Balanced Substring II

The problem gives us a string s that contains only three possible characters: 'a', 'b', and 'c'. We must find the longest substring where every distinct character in that substring appears the same number of times.

leetcodemediumhash-tablestringprefix-sum
LeetCode 3712 - Sum of Elements With Frequency Divisible by K

The problem asks us to compute the sum of all elements in the array whose total frequency is divisible by a given integer k. To understand the requirement clearly, we need to focus on two important details: First, we must determine how many times each number appears in the array.

leetcodeeasyarrayhash-tablecounting
LeetCode 3811 - Number of Alternating XOR Partitions

We are given an array nums and two distinct target XOR values, target1 and target2. A partition divides the array into contiguous, non-empty blocks. Every element must belong to exactly one block, and the blocks must cover the entire array.

leetcodemediumarrayhash-tabledynamic-programmingbit-manipulation
LeetCode 3711 - Maximum Transactions Without Negative Balance

Here is a complete, detailed technical solution guide for LeetCode 3711 - Maximum Transactions Without Negative Balance, following your formatting instructions precisely. The problem provides an array transactions of integers representing sequential money movements in an account.

leetcodemediumarraygreedyheap-(priority-queue)
LeetCode 3710 - Maximum Partition Factor

The problem asks us to split a set of n points in a 2D Cartesian plane into exactly two non-empty groups, such that the minimum Manhattan distance among all pairs of points within each group (the partition factor) is maximized.

leetcodehardarraybinary-searchdepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 3808 - Find Emotionally Consistent Users

This problem asks us to analyze user reactions and determine which users exhibit a strong preference for a particular reaction type. The input is a table named reactions, where each row represents a reaction given by a user to a specific content item.

leetcodemedium
LeetCode 3709 - Design Exam Scores Tracker

This problem asks us to design a system that tracks Alice's exam scores over time and efficiently computes the total score for any given time interval.

leetcodemediumarraybinary-searchdesignprefix-sum
LeetCode 3807 - Minimum Cost to Repair Edges to Traverse a Graph

The problem presents an undirected graph with n nodes labeled from 0 to n-1 and m edges. Each edge has a repair cost, and initially, all edges are damaged. We can spend a certain amount of money to repair all edges whose cost is less than or equal to that amount.

leetcodemediumbinary-searchbreadth-first-searchgraph-theory
LeetCode 3704 - Count No-Zero Pairs That Sum to N

The problem asks us to count all pairs of positive integers (a, b) such that their sum equals a given integer n and neither a nor b contains the digit 0 in their decimal representation. These integers are called no-zero integers.

leetcodehardmathdynamic-programming
LeetCode 3805 - Count Caesar Cipher Pairs

We are given an array words containing n lowercase strings. Every string has the same length m. Two strings are considered similar if we can repeatedly apply the following operation to either string: - Shift every character forward by one position in the alphabet.

leetcodemediumarrayhash-tablemathstringcounting
LeetCode 3806 - Maximum Bitwise AND After Increment Operations

The problem asks us to find the maximum possible bitwise AND of any subset of size m from an array nums after performing up to k increment operations. Each operation allows us to increase any element in the array by 1.

leetcodehardarraygreedybit-manipulationsorting
LeetCode 3702 - Longest Subsequence With Non-Zero Bitwise XOR

We are given an integer array nums, and we must determine the maximum possible length of a subsequence whose bitwise XOR is not equal to zero. A subsequence is formed by deleting zero or more elements from the array while preserving the relative order of the remaining elements.

leetcodemediumarraybit-manipulation
LeetCode 3804 - Number of Centered Subarrays

The problem asks us to count the number of centered subarrays in a given integer array nums. A subarray is called centered if the sum of its elements is equal to at least one element within that subarray.

leetcodemediumarrayhash-tableenumeration
LeetCode 3700 - Number of ZigZag Arrays II

The problem asks us to count the number of arrays of length n where each element is in the range [l, r], no two consecutive elements are equal, and no three consecutive elements are strictly increasing or strictly decreasing. These arrays are termed ZigZag arrays.

leetcodehardmathdynamic-programming
LeetCode 3802 - Number of Ways to Paint Sheets

The problem asks us to compute the number of ways to paint n sheets using exactly two distinct colors, subject to constraints on the maximum number of sheets each color can paint.

leetcodehard
LeetCode 3699 - Number of ZigZag Arrays I

Here is the complete technical solution guide for LeetCode 3699 - Number of ZigZag Arrays I, formatted exactly according to your specifications. The problem asks us to count arrays of length n where each element is within the range [l, r] and satisfies the ZigZag constraints.

leetcodeharddynamic-programmingprefix-sum
LeetCode 3799 - Word Squares II

We are given an array of distinct 4-letter words. Our goal is to construct every valid word square consisting of exactly four different words: - top forms the top row. - bottom forms the bottom row. - left forms the left column. - right forms the right column.

leetcodemediumarraystringbacktrackingsortingenumeration
LeetCode 3801 - Minimum Cost to Merge Sorted Lists

We are given between 2 and 12 sorted lists. At any moment we may choose any two existing lists and merge them. If the two lists are and , the merge cost is After the merge, the two lists disappear and are replaced by their sorted union.

leetcodehardarraytwo-pointersbinary-searchdynamic-programmingbit-manipulation
LeetCode 3698 - Split Array With Minimum Difference

I can write the full detailed guide, but I need to flag one issue first: the problem statement for LeetCode 3698 - Split Array With Minimum Difference appears inconsistent with the provided Go stub and the current LeetCode catalog.

leetcodemediumarrayprefix-sum
LeetCode 3696 - Maximum Distance Between Unequal Words in Array I

The problem gives us an array of strings, words, and asks us to find the maximum distance between two indices i and j where the words at those positions are different. More formally, we want to find two indices such that: - words[i] !

leetcodeeasyarraystring
LeetCode 3692 - Majority Frequency Characters

The problem asks us to analyze the frequency distribution of characters in a string and identify a particular group of characters based on how often they appear. We are given a string s containing only lowercase English letters.

leetcodeeasyhash-tablestringcounting
LeetCode 3685 - Subsequence Sum After Capping Elements

Here is a complete, rigorous study companion-style solution guide for LeetCode 3685 - Subsequence Sum After Capping Elements, following your requested format and voice. We are given an integer array nums of size n and a positive integer k.

leetcodemediumarraytwo-pointersdynamic-programmingsorting
LeetCode 3795 - Minimum Subarray Length With Distinct Sum At Least K

This problem asks us to find the shortest contiguous subarray whose distinct-value sum is at least k. The important detail is that we do not sum all elements in the subarray.

leetcodemediumarrayhash-tablesliding-window
LeetCode 3794 - Reverse String Prefix

This problem gives us a string s and an integer k. Our task is to reverse only the first k characters of the string while leaving the remaining characters unchanged.

leetcodeeasytwo-pointersstring
LeetCode 3765 - Complete Prime Number

The problem gives us a positive integer num and asks whether it is a Complete Prime Number. A number qualifies as a Complete Prime Number if every prefix and every suffix of its decimal representation is prime. For a number with digits d1 d2 d3 ...

leetcodemediummathenumerationnumber-theory
LeetCode 3755 - Find Maximum Balanced XOR Subarray Length

This problem asks us to find the longest contiguous subarray that simultaneously satisfies two independent conditions: 1. The bitwise XOR of all elements in the subarray is equal to 0. 2. The subarray contains an equal number of even and odd elements.

leetcodemediumarrayhash-tablebit-manipulationprefix-sum
LeetCode 3742 - Maximum Path Score in a Grid

This problem presents a grid of size m x n where each cell contains a value of 0, 1, or 2. Each cell contributes both a score and a cost: a cell with value 0 adds 0 to both score and cost, a cell with value 1 adds 1 to score and 1 to cost, and a cell with value 2 adds 2 to…

leetcodemediumarraydynamic-programmingmatrix
LeetCode 3729 - Count Distinct Subarrays Divisible by K in Sorted Array

The problem asks us to find the number of distinct subarrays in a sorted array nums such that the sum of elements in the subarray is divisible by a given integer k.

leetcodehardarrayhash-tableprefix-sum
LeetCode 3718 - Smallest Missing Multiple of K

The problem asks us to find the smallest positive multiple of k that is not present in a given integer array nums. In other words, if we consider the infinite sequence of numbers k, 2k, 3k, 4k…, we need to identify the first number in this sequence that does not appear in nums.

leetcodeeasyarrayhash-table
LeetCode 3708 - Longest Fibonacci Subarray

The problem gives us an array nums consisting of positive integers and asks us to find the length of the longest contiguous subarray that satisfies the Fibonacci property. A subarray is a contiguous segment of the original array.

leetcodemediumarray
LeetCode 3703 - Remove K-Balanced Substrings

We are given a string s consisting only of '(' and ')', along with an integer k. A substring is considered k-balanced if it is exactly: For example: - k = 1 → "()" - k = 2 → "(())" - k = 3 → "((()))" The operation is not performed just once. Instead, we repeatedly: 1.

leetcodemediumstringstacksimulation
LeetCode 3691 - Maximum Total Subarray Value II

The problem is asking us to select exactly k distinct subarrays from a given integer array nums such that the sum of their "values" is maximized. Each subarray's value is calculated as the difference between its maximum and minimum elements.

leetcodehardarraygreedysegment-treeheap-(priority-queue)
LeetCode 3690 - Split and Merge Array Transformation

The problem gives us two arrays, nums1 and nums2, of equal length n. We are allowed to repeatedly perform a special operation on nums1.

leetcodemediumarrayhash-tablebreadth-first-search
LeetCode 3681 - Maximum XOR of Subsequences

The problem gives us an array nums of non-negative integers. We must choose two subsequences: - The first subsequence has XOR value X. - The second subsequence has XOR value Y. The two subsequences: - May be empty.

leetcodehardarraymathgreedybit-manipulation
LeetCode 3679 - Minimum Discards to Balance Inventory

This problem models a stream of arriving items. On each day, exactly one item arrives, and each item has a type represented by an integer. We are given two parameters: - w, the size of the sliding window. - m, the maximum number of times any item type may appear within a window.

leetcodemediumarrayhash-tablesliding-windowsimulationcounting
LeetCode 3661 - Maximum Walls Destroyed by Robots

This problem takes place on a one dimensional number line. We are given positions of robots and positions of walls. Every robot owns exactly one bullet, and that bullet can be fired either to the left or to the right.

leetcodehardarraybinary-searchdynamic-programmingsorting
LeetCode 3654 - Minimum Sum After Divisible Sum Deletions

This problem gives us an array nums containing positive integers and an integer k. We may repeatedly remove any contiguous subarray whose sum is divisible by k.

leetcodemediumarrayhash-tabledynamic-programmingprefix-sum
LeetCode 3642 - Find Books with Polarized Opinions

The problem asks us to identify books that exhibit polarized opinions based on reading session ratings. We have two tables: books, which contains metadata about each book including its title, author, genre, and number of pages, and readingsessions, which records individual…

leetcodemedium
LeetCode 3635 - Earliest Finish Time for Land and Water Rides II

Great! We will cover LeetCode 3627 - Maximum Median Sum of Subsequences of Size 3 in a full, comprehensive technical guide following your formatting requirements. The problem gives us an integer array nums with a length divisible by 3.

leetcodemediumarraytwo-pointersbinary-searchgreedysorting
LeetCode 3611 - Find Overbooked Employees

This problem asks us to identify employees who spend an excessive amount of their working time in meetings. We are given two tables: The employees table contains employee information, including their unique identifier, name, and department.

leetcodemediumdatabase
LeetCode 3609 - Minimum Moves to Reach Target in Grid

The problem asks us to determine the minimum number of moves to reach a target point (tx, ty) from a starting point (sx, sy) on an infinite 2D grid. The movement rules are specific: from any point (x, y), you can move either right by max(x, y) units or up by max(x, y) units.

leetcodehardmath
LeetCode 3595 - Once Twice

The problem provides an integer array nums where every element appears exactly three times, except for one element that appears once and one element that appears twice.

leetcodemediumarraybit-manipulation
LeetCode 3593 - Minimum Increments to Equalize Leaf Paths

We are given a rooted tree with root node 0. Every node has a cost, and the score of a root-to-leaf path is the sum of the costs of all nodes along that path. We are allowed to increase the cost of any nodes by any non-negative amount.

leetcodemediumarraydynamic-programmingtreedepth-first-search
LeetCode 3590 - Kth Smallest Path XOR Sum

The problem asks us to work with an undirected tree rooted at node 0, where each node has a value vals[i] and a parent par[i].

leetcodehardarraytreedepth-first-searchordered-set
LeetCode 3572 - Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values

The problem gives us two arrays, x and y, both of length n. Each position i represents a pair (x[i], y[i]). We need to select exactly three distinct indices i, j, and k such that the corresponding x values are all different: - x[i] != x[j] - x[j] != x[k] - x[k] !

leetcodemediumarrayhash-tablegreedysortingheap-(priority-queue)
LeetCode 3566 - Partition Array into Two Equal Product Subsets

Here’s a detailed technical solution guide for LeetCode 3566 following your formatting rules: The problem asks us to determine whether a given array of distinct positive integers can be split into two non-empty, disjoint subsets, such that the product of the elements in each…

leetcodemediumarraybit-manipulationrecursionenumeration
LeetCode 3558 - Number of Ways to Assign Edge Weights I

We are given an undirected tree rooted at node 1. Every edge initially has weight 0, and we must assign each edge a weight of either 1 or 2. The problem asks us to choose any node x that has the maximum depth in the tree.

leetcodemediummathtreedepth-first-search
LeetCode 3557 - Find Maximum Number of Non Intersecting Substrings

This problem asks us to identify the maximum number of non-intersecting substrings from a given string word such that each substring is at least four characters long and starts and ends with the same character.

leetcodemediumhash-tablestringdynamic-programminggreedy
LeetCode 3556 - Sum of Largest Prime Substrings

The problem requires identifying prime numbers from all possible substrings of a given string of digits and summing the three largest unique primes.

leetcodemediumhash-tablemathstringsortingnumber-theory
LeetCode 3534 - Path Existence Queries in a Graph II

This problem asks us to compute the shortest path between nodes in an implicit undirected graph defined by a nums array and a maxDiff. Each node i corresponds to nums[i]. There is an edge between nodes i and j if the absolute difference of their values is at most maxDiff.

leetcodehardarraytwo-pointersbinary-searchdynamic-programminggreedybit-manipulationgraph-theorysorting
LeetCode 3528 - Unit Conversion I

The problem is asking us to compute, for each unit type from 0 to n-1, the number of that unit equivalent to a single unit of type 0. We are given a list of direct conversion relationships between units.

leetcodemediumdepth-first-searchbreadth-first-searchgraph-theory
LeetCode 3521 - Find Product Recommendation Pairs

This problem asks us to identify product pairs that are frequently purchased by the same customers. The goal is to support a recommendation feature similar to "Customers who bought this also bought...

leetcodemediumdatabase
LeetCode 3519 - Count Numbers with Non-Decreasing Digits

We are given two very large integers l and r as decimal strings and a base b where 2 ≤ b ≤ 10. For every integer x in the inclusive range [l, r], we consider its representation in base b.

leetcodehardmathstringdynamic-programming
LeetCode 3506 - Find Time Required to Eliminate Bacterial Strains

This problem asks us to find the minimum time required to eliminate all bacterial strains given a single initial white blood cell (WBC) and the ability of WBCs to split into two after some splitTime.

leetcodehardarraymathgreedyheap-(priority-queue)
LeetCode 3505 - Minimum Operations to Make Elements Within K Subarrays Equal

You are given an integer array nums, and you want to create at least k non-overlapping subarrays. Every chosen subarray must have length exactly x, and after performing some modifications, every element inside each chosen subarray must become equal.

leetcodehardarrayhash-tablemathdynamic-programmingsliding-windowheap-(priority-queue)
LeetCode 3504 - Longest Palindrome After Substring Concatenation II

We are given two strings, s and t. We may choose any substring from s and any substring from t. Either substring is allowed to be empty.

leetcodehardtwo-pointersstringdynamic-programming
LeetCode 3482 - Analyze Organization Hierarchy

This problem is a hierarchical organization analysis task over an employee table that forms a tree structure. Each employee has a unique employeeid, a name, a salary, and a managerid. The employee whose managerid is NULL is the CEO and serves as the root of the organization tree.

leetcodeharddatabase
LeetCode 3468 - Find the Number of Copy Arrays

We are given an array original and a range constraint for every position in the form of bounds[i] = [ui, vi]. We need to count how many arrays copy satisfy two conditions.

leetcodemediumarraymath
LeetCode 3464 - Maximize the Distance Between Points on a Square

We are given a square of side length side. Every point in the input lies somewhere on the boundary of this square. We must choose exactly k points from the given set.

leetcodehardarraymathbinary-searchgeometrysorting
LeetCode 3453 - Separate Squares I

We are given a collection of axis-aligned squares. Each square is represented by three integers: - xi: x-coordinate of the bottom-left corner - yi: y-coordinate of the bottom-left corner - li: side length The square therefore occupies the region: We must find the smallest…

leetcodemediumarraybinary-search
LeetCode 3445 - Maximum Difference Between Even and Odd Frequency II

We are given a string s consisting only of digits '0' through '4', and an integer k. For any substring subs whose length is at least k, we may choose two characters: - Character a must appear an odd number of times in the substring.

leetcodehardstringsliding-windowenumerationprefix-sum
LeetCode 3419 - Minimize the Maximum Edge Weight of Graph

The problem is asking us to manipulate a directed weighted graph in order to minimize the maximum edge weight while satisfying two constraints: every node must be able to reach node 0, and no node may have more outgoing edges than a given threshold.

leetcodemediumbinary-searchdepth-first-searchbreadth-first-searchgraph-theoryshortest-path
LeetCode 3414 - Maximum Score of Non-overlapping Intervals

This problem combines weighted interval scheduling with an additional constraint: we may select at most 4 intervals, and if multiple selections achieve the same maximum total weight, we must return the lexicographically smallest list of original indices.

leetcodehardarraybinary-searchdynamic-programmingsorting
LeetCode 3412 - Find Mirror Score of a String

We are given a lowercase English string s. Every letter has a unique "mirror" letter obtained by reversing the alphabet. For example: - 'a' ↔ 'z' - 'b' ↔ 'y' - 'c' ↔ 'x' and so on. We process the string from left to right.

leetcodemediumhash-tablestringstacksimulation
LeetCode 3406 - Find the Lexicographically Largest String From the Box II

We are given a string word of length n and an integer numFriends. In every round, Alice splits the entire string into exactly numFriends non-empty pieces. Every possible valid split is considered exactly once. Every piece produced by every split is placed into a box.

leetcodehardtwo-pointersstring
LeetCode 3401 - Find Circular Gift Exchange Chains

Here’s a full technical solution guide following your requested format for LeetCode 3401 - Find Circular Gift Exchange Chains: This problem asks us to analyze a table of gift exchanges in a Secret Santa setting and identify circular chains of gift exchanges.

leetcodeharddatabase
LeetCode 3402 - Minimum Operations to Make Columns Strictly Increasing

The problem gives us a matrix grid of size m x n containing non-negative integers. Each column must become strictly increasing, meaning for each column j, the condition grid[i][j] < grid[i+1][j] must hold for all 0 <= i < m-1.

leetcodeeasyarraygreedymatrix
LeetCode 3770 - Largest Prime from Consecutive Prime Sum

The problem gives us an integer n and asks us to find the largest prime number that satisfies two conditions: 1. It is less than or equal to n. 2. It can be written as the sum of one or more consecutive prime numbers starting from 2.

leetcodemediumarraymathnumber-theory
LeetCode 3768 - Minimum Inversion Count in Subarrays of Fixed Length

We are given an array nums of length n and an integer k. For every contiguous subarray of length k, we must compute its inversion count, then return the smallest inversion count among all such windows.

leetcodehardarraysegment-treesliding-window
LeetCode 3764 - Most Common Course Pairs

The coursecompletions table records every course completed by every user. Each row contains the user, the course they completed, the completion date, and the rating they gave that course. The problem asks us to identify common learning pathways among strong students.

leetcodehard
LeetCode 3762 - Minimum Operations to Equalize Subarrays

We are given an array nums and a fixed integer k. A single operation allows us to choose any element and either increase it by exactly k or decrease it by exactly k. We may perform as many operations as needed. For each query [l, r], we only consider the subarray nums[l..r].

leetcodehardarraymathbinary-searchsegment-tree
LeetCode 3760 - Maximum Substrings With Distinct Start

The problem asks us to split a string into as many non-empty substrings as possible, with one important restriction: the first character of every substring must be different from the first character of every other substring.

leetcodemediumhash-tablestring
LeetCode 3751 - Total Waviness of Numbers in Range I

This problem asks us to compute the total waviness of every integer in an inclusive range [num1, num2]. For a single number, waviness is defined as the number of digits that are either peaks or valleys. A digit is a peak if it is strictly larger than both adjacent digits.

leetcodemediummathdynamic-programmingenumeration
LeetCode 3748 - Count Stable Subarrays

The problem asks us to count "stable" subarrays within a given array nums. A subarray is stable if it contains no inversions, which means that for any two indices i < j in the subarray, nums[i] <= nums[j]. Essentially, a stable subarray is non-decreasing.

leetcodehardarraybinary-searchprefix-sum
LeetCode 3745 - Maximize Expression of Three Elements

The problem gives us an integer array nums and asks us to choose three elements a, b, and c from distinct indices such that the expression: is as large as possible. The important detail is that the three elements must come from different positions in the array.

leetcodeeasyarraygreedysortingenumeration
LeetCode 3744 - Find Kth Character in Expanded String

The problem gives us a string s containing one or more lowercase words separated by single spaces. From this original string, we conceptually build a new string t using a special expansion rule.

leetcodemediumstring
LeetCode 3743 - Maximize Cyclic Partition Score

We are given a cyclic array nums, which means the array is considered to wrap around from the last element back to the first element. We want to partition the entire cycle into at most k contiguous subarrays.

leetcodehardarraydynamic-programming
LeetCode 3734 - Lexicographically Smallest Palindromic Permutation Greater Than Target

We are given two strings, s and target, of the same length n. The goal is to rearrange the characters of s into a palindrome and then choose, among all possible palindromic permutations, the lexicographically smallest one that is strictly greater than target.

leetcodehardtwo-pointersstringenumeration
LeetCode 3727 - Maximum Alternating Sum of Squares

We are given an integer array nums, and we are allowed to rearrange its elements in any order before computing a score. The score of a rearranged array arr is defined as: The sign alternates between positive and negative positions.

leetcodemediumarraygreedysorting
LeetCode 3726 - Remove Zeros in Decimal Representation

The problem gives us a positive integer n and asks us to remove every digit '0' from its decimal representation. After all zero digits have been removed, we must return the resulting value as an integer. In other words, we first view the number as a sequence of decimal digits.

leetcodeeasymathsimulation
LeetCode 3723 - Maximize Sum of Squares of Digits

The problem asks us to construct a positive integer n of exactly num digits such that the sum of its digits equals sum.

leetcodemediummathgreedy
LeetCode 3716 - Find Churn Risk Customers

This problem asks us to identify subscribers who appear likely to churn based on their subscription history. The data is stored in the subscriptionevents table, where each row represents a subscription-related action performed by a user.

leetcodemedium
LeetCode 3715 - Sum of Perfect Square Ancestors

This problem asks us to compute a sum across all non-root nodes in a tree based on ancestor relationships and the property of perfect squares. We are given a rooted tree of n nodes, represented as an edge list. Each node has a positive integer value from the nums array.

leetcodehardarrayhash-tablemathtreedepth-first-searchcountingnumber-theory
LeetCode 3707 - Equal Score Substrings

The problem asks us to determine if a given string s can be split into two non-empty substrings such that the sum of the alphabetic positions of characters in the left substring is equal to the sum in the right substring.

leetcodeeasystringprefix-sum