brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 3662 - Filter Characters by Frequency

This problem asks us to filter a string based on character frequency while preserving the original order of characters. We are given a string s consisting only of lowercase English letters and an integer k.

leetcodeeasyhash-tablestringcounting
LeetCode 3663 - Find The Least Frequent Digit

The problem asks us to find the least frequent digit in the decimal representation of a given integer n. In other words, we need to count how many times each digit from 0 to 9 appears in the number, and then return the smallest digit that occurs the fewest times.

leetcodeeasyarrayhash-tablemathcounting
LeetCode 3658 - GCD of Odd and Even Sums

The problem asks us to calculate the greatest common divisor (GCD) of two specific sums derived from an integer input n. The first sum, sumOdd, is the sum of the first n positive odd numbers, and the second sum, sumEven, is the sum of the first n positive even numbers.

leetcodeeasymathnumber-theory
LeetCode 3657 - Find Loyal Customers

This problem is a SQL aggregation and filtering task. We are given a table named customertransactions that contains every transaction performed by customers. Each row represents either a purchase or a refund.

leetcodemedium
LeetCode 3651 - Minimum Cost Path with Teleportations

The problem asks us to find the minimum cost to travel from the top-left corner (0, 0) of a 2D grid to the bottom-right corner (m - 1, n - 1). Each cell contains a non-negative integer representing its cost. There are two ways to move: 1.

leetcodehardarraydynamic-programmingmatrix
LeetCode 3655 - XOR After Range Multiplication Queries II

We are given an array nums and a list of queries. Each query has the form: For a query, we start at index li and repeatedly jump forward by ki until we pass ri. Every visited position is multiplied by vi, and the result is taken modulo 10^9 + 7.

leetcodehardarraydivide-and-conquer
LeetCode 3653 - XOR After Range Multiplication Queries I

We are given an integer array nums and a list of queries. Each query has the form: For a query, we start at index li and repeatedly move forward by ki positions until we exceed ri.

leetcodemediumarraydivide-and-conquersimulation
LeetCode 3652 - Best Time to Buy and Sell Stock using Strategy

This problem asks us to calculate the maximum possible profit from a stock trading strategy with the option to modify it once in a very specific way.

leetcodemediumarraysliding-windowprefix-sum
LeetCode 3647 - Maximum Weight in Two Bags

This problem asks us to distribute a set of items, each with a given weight, into two separate bags with fixed capacity limits, in order to maximize the total weight placed across both bags.

leetcodemediumarraydynamic-programming
LeetCode 3648 - Minimum Sensors to Cover Grid

The problem gives an n × m grid where each cell is identified by coordinates (r, c). A sensor can be placed on any cell, and its coverage is defined using Chebyshev distance. Specifically, a sensor at (r, c) covers every cell (r2, c2) such that max(|r - r2|, |c - c2|) ≤ k.

leetcodemediummath
LeetCode 3646 - Next Special Palindrome Number

This problem asks us to construct a number system under two simultaneous constraints and then perform a “next greater element” query over that constrained set.

leetcodehardbacktrackingbit-manipulation
LeetCode 3640 - Trionic Array II

We are given an integer array nums, and we must find the maximum possible sum of a contiguous subarray that follows a very specific shape: 1. It first increases strictly. 2. Then decreases strictly. 3. Then increases strictly again. More formally, for a subarray nums[l...

leetcodehardarraydynamic-programming
LeetCode 3643 - Flip Square Submatrix Vertically

This problem gives us an m x n matrix called grid and three integers: x, y, and k. The values x and y specify the top-left corner of a square submatrix, while k specifies the side length of that square.

leetcodeeasyarraytwo-pointersmatrix
LeetCode 3641 - Longest Semi-Repeating Subarray

We are given an integer array nums and an integer k. A subarray is considered semi-repeating if the number of distinct values that appear more than once inside that subarray is at most k.

leetcodemediumarrayhash-tablesliding-window
LeetCode 3636 - Threshold Majority Queries

The problem asks us to process multiple queries on a given array nums where each query specifies a subarray defined by [li, ri] and a threshold. For each query, we need to find an element in the subarray that appears at least threshold times.

leetcodehardarrayhash-tablebinary-searchdivide-and-conquercountingprefix-sum
LeetCode 3638 - Maximum Balanced Shipments

We are given an array weight representing parcels arranged in a line. We must partition some prefix-suffix segments of this array into a collection of non-overlapping contiguous subarrays called shipments.

leetcodemediumarraydynamic-programmingstackgreedymonotonic-stack
LeetCode 3632 - Subarrays with XOR at Least K

This problem asks us to count the number of contiguous subarrays of a given array nums such that the bitwise XOR of all elements in the subarray is greater than or equal to a given integer k. The input array nums consists of positive integers, and k is a non-negative integer.

leetcodehardarraybit-manipulationtrieprefix-sum
LeetCode 3630 - Partition Array for Maximum XOR and AND

The problem asks us to partition an integer array nums into three subsequences A, B, and C such that every element belongs to exactly one subsequence.

leetcodehardarraymathgreedybit-manipulationenumeration
LeetCode 3625 - Count Number of Trapezoids II

The problem asks us to count the number of unique trapezoids that can be formed from a set of points on a 2D Cartesian plane. Each point is given as a pair of integers representing its x and y coordinates.

leetcodehardarrayhash-tablemathgeometry
LeetCode 3626 - Find Stores with Inventory Imbalance

This problem asks us to identify stores with an inventory imbalance. Specifically, for each store, we need to compare the quantity of the most expensive product against the quantity of the cheapest product.

leetcodemedium
LeetCode 3620 - Network Recovery Pathways

We are given a directed acyclic graph (DAG) with n nodes numbered from 0 to n - 1. Each directed edge is represented as: and stored in: We are also given a boolean array online, where: The problem guarantees that node 0 and node n - 1 are always online.

leetcodehardarraybinary-searchdynamic-programminggraph-theorytopological-sortheap-(priority-queue)shortest-path
LeetCode 3617 - Find Students with Study Spiral Pattern

The task asks us to identify students who exhibit a very specific behavioral pattern in their study history, called a Study Spiral Pattern. We are given two relational tables: one describing students and another describing their study sessions over time.

leetcodehard
LeetCode 3622 - Check Divisibility by Digit Sum and Product

The problem asks us to determine if a given positive integer n is divisible by the sum of two specific quantities derived from its digits: the digit sum and the digit product.

leetcodeeasymath
LeetCode 3612 - Process String with Special Operations I

The problem asks us to simulate the construction of a string called result by processing an input string s from left to right. The input string contains lowercase English letters and three special operators: , , and %.

leetcodemediumstringsimulation
LeetCode 3619 - Count Islands With Total Value Divisible by K

The problem is asking us to count islands in a 2D grid where the sum of the values in each island is divisible by a given integer k.

leetcodemediumarraydepth-first-searchbreadth-first-searchunion-findmatrix
LeetCode 3618 - Split Array by Prime Indices

The problem gives us an integer array nums and asks us to divide its elements into two groups based on their indices. Array A contains all elements whose indices are prime numbers. Array B contains all remaining elements, meaning indices that are not prime.

leetcodemediumarraymathnumber-theory
LeetCode 3614 - Process String with Special Operations II

The problem defines a transformation process over a string s that contains lowercase letters and three special operation characters: '', '', and '%'. We process the string from left to right, maintaining a dynamically changing result string.

leetcodehardstringsimulation
LeetCode 3605 - Minimum Stability Factor of Array

We are given an array nums and an integer maxC. A subarray is called stable if the greatest common divisor (HCF/GCD) of all elements in that subarray is at least 2. The stability factor of the entire array is defined as the length of the longest stable subarray.

leetcodehardarraymathbinary-searchgreedysegment-treenumber-theory
LeetCode 3606 - Coupon Code Validator

The problem is asking us to validate a set of coupons based on three criteria: the coupon code must be a non-empty string containing only alphanumeric characters or underscores, the business line must belong to a set of four predefined categories, and the coupon must be active.

leetcodeeasyarrayhash-tablestringsorting
LeetCode 3604 - Minimum Time to Reach Destination in Directed Graph

This problem asks us to compute the minimum time required to reach the last node in a directed graph where each edge has a time window constraint.

leetcodemediumgraph-theoryheap-(priority-queue)shortest-path
LeetCode 3607 - Power Grid Maintenance

The problem gives an undirected graph of c power stations labeled from 1 to c, connected by bidirectional cables. These connections define connected components, which are referred to as power grids.

leetcodemediumarrayhash-tabledepth-first-searchbreadth-first-searchunion-findgraph-theoryheap-(priority-queue)ordered-set
LeetCode 3599 - Partition Array to Minimize XOR

This problem asks us to partition an array of integers, nums, into exactly k non-empty contiguous subarrays, and then compute the bitwise XOR of each subarray. The goal is to minimize the maximum XOR among these subarrays.

leetcodemediumarraydynamic-programmingbit-manipulationprefix-sum
LeetCode 3594 - Minimum Time to Transport All Individuals

This problem is a shortest-path optimization over a highly constrained state space where you are repeatedly moving groups of people across a river using a single boat.

leetcodehardarraybit-manipulationgraph-theoryheap-(priority-queue)shortest-pathbitmask
LeetCode 3597 - Partition String

We are given a string s and must partition it into segments according to a very specific process. We start at the current position in the string and begin building a segment character by character.

leetcodemediumhash-tablestringtriesimulation
LeetCode 3415 - Find Products with Three Consecutive Digits

This is a SQL database problem involving pattern matching on strings. We are given a table named Products with two columns: | Column | Description | | --- | --- | | productid | Unique identifier for each product | | name | Product name string | The goal is to return all…

leetcodeeasydatabase
LeetCode 3596 - Minimum Cost Path with Alternating Directions I

This problem requires computing the minimum total cost to traverse a grid from the top-left corner (0, 0) to the bottom-right corner (m - 1, n - 1) while following a strict alternating movement pattern. Each cell (i, j) has a cost to enter, calculated as (i + 1) (j + 1).

leetcodemediummathbrainteaser
LeetCode 3592 - Inverse Coin Change

The problem gives us a 1-indexed array numWays, where numWays[i] indicates the number of ways to form a total amount i using an infinite supply of some unknown coin denominations. The goal is to recover the original set of coin denominations.

leetcodemediumarraydynamic-programming
LeetCode 3591 - Check if Any Element Has Prime Frequency

This problem asks us to determine whether any number in an array appears a prime number of times. In other words, for each unique number in the input array nums, we calculate its frequency-the number of occurrences-and check if that frequency is a prime number.

leetcodeeasyarrayhash-tablemathcountingnumber-theory
LeetCode 3589 - Count Prime-Gap Balanced Subarrays

We are given an integer array nums and an integer k. We must count how many contiguous subarrays satisfy two conditions: 1. The subarray contains at least two prime numbers. 2.

leetcodemediumarraymathqueuesliding-windownumber-theorymonotonic-queue
LeetCode 3586 - Find COVID Recovery Patients

The task is to identify patients who have recovered from COVID based on their testing history. We are given two tables: one containing patient demographic information and another containing COVID test records with timestamps and results.

leetcodemediumdatabase
LeetCode 3585 - Find Weighted Median Node in Tree

We are given a weighted tree with n nodes. A tree is an undirected connected graph with exactly n - 1 edges, which guarantees that there is exactly one simple path between any two nodes. Each edge has a positive weight.

leetcodehardarraybinary-searchdynamic-programmingbit-manipulationtreedepth-first-search
LeetCode 3588 - Find Maximum Area of a Triangle

We are given n distinct points on a 2D Cartesian plane. Each point is represented as [x, y]. We must choose any three points that form a non-degenerate triangle, meaning the area must be strictly greater than zero.

leetcodemediumarrayhash-tablemathgreedygeometryenumeration
LeetCode 3582 - Generate Tag for Video Caption

The problem asks us to transform a given caption string into a valid video tag following a strict sequence of rules. The input is a single string caption consisting only of English letters and spaces. These words must be transformed into a single hashtag-style identifier.

leetcodeeasystringsimulation
LeetCode 3580 - Find Consistently Improving Employees

The task asks us to identify employees whose performance has consistently improved over their most recent three performance reviews.

leetcodemediumdatabase
LeetCode 3579 - Minimum Steps to Convert String with Operations

The problem asks us to transform one string, word1, into another string, word2, using the minimum number of operations. Both strings have equal length and consist only of lowercase English letters.

leetcodehardstringdynamic-programming
LeetCode 3578 - Count Partitions With Max-Min Difference at Most K

We are given an array nums and an integer k. We want to split the array into one or more contiguous, non-empty segments. Every element must belong to exactly one segment, and the segments must preserve the original order of the array.

leetcodemediumarraydynamic-programmingqueuesliding-windowprefix-summonotonic-queue
LeetCode 3577 - Count the Number of Computer Unlocking Permutations

The problem presents a set of n computers, each with a unique password complexity represented in an array complexity of length n. The computers are labeled 0 to n - 1, and only computer 0 is initially unlocked.

leetcodemediumarraymathbrainteasercombinatorics
LeetCode 3573 - Best Time to Buy and Sell Stock V

This problem extends the classic stock trading dynamic programming family by allowing two different kinds of transactions. A normal transaction consists of buying first and selling later. If the stock price rises, the profit is: A short selling transaction reverses the order.

leetcodemediumarraydynamic-programming
LeetCode 3574 - Maximize Subarray GCD Score

The problem asks us to choose a contiguous subarray from an array of positive integers after performing at most k doubling operations, where each element can be doubled at most once.

leetcodehardarraymathenumerationnumber-theory
LeetCode 3571 - Find the Shortest Superstring II

This problem asks us to construct the shortest string that contains two given strings, s1 and s2, as substrings. In other words, we are asked to merge s1 and s2 in such a way that no unnecessary characters are added, but both strings appear contiguously somewhere in the…

leetcodeeasystring
LeetCode 3570 - Find Books with No Available Copies

This problem asks us to identify books in a library system that are both fully unavailable for borrowing and currently have active borrowers who have not returned them yet. We are given two tables.

leetcodeeasydatabase
LeetCode 3567 - Minimum Absolute Difference in Sliding Submatrix

The problem requires computing a specific statistic for every contiguous k x k submatrix of a given m x n integer matrix grid. For each submatrix, we must find the minimum absolute difference between any two distinct elements.

leetcodemediumarraysortingmatrix
LeetCode 3560 - Find Minimum Log Transportation Cost

The problem asks us to transport two logs of lengths n and m using three trucks, where each truck can carry a log of length at most k. If a log is longer than k, it must be cut into smaller pieces.

leetcodeeasymath
LeetCode 3565 - Sequential Grid Path Cover

The problem asks us to find a path that visits every cell of a given m x n grid exactly once while visiting certain numbered cells in a specified order. Specifically, the grid contains integers from 1 to k in exactly one cell each, and the rest of the cells are zeros.

leetcodemediumarrayrecursionmatrix
LeetCode 3563 - Lexicographically Smallest String After Adjacent Removals

The problem asks us to find the lexicographically smallest string that can be formed by repeatedly removing adjacent pairs of characters in a string s that are consecutive in the alphabet. Consecutive letters can be in either order (e.g.

leetcodehardstringdynamic-programming
LeetCode 3561 - Resulting String After Adjacent Removals

The problem asks us to repeatedly remove pairs of adjacent characters in a string that are consecutive in the alphabet, considering the alphabet as circular.

leetcodemediumstringstacksimulation
LeetCode 3559 - Number of Ways to Assign Edge Weights II

We are given an undirected tree with n nodes, rooted at node 1. Every edge will eventually receive a weight of either 1 or 2. For each query [u, v], we only care about the unique path connecting u and v. All edges outside that path are completely irrelevant and should be ignored.

leetcodehardarraymathdynamic-programmingbit-manipulationtreedepth-first-search
LeetCode 3549 - Multiply Two Polynomials

The input arrays represent polynomials in coefficient form. If: then it represents: Similarly: represents: The task is to compute the product polynomial: and return its coefficients.

leetcodehardarraymath
LeetCode 3554 - Find Category Recommendation Pairs

This is a SQL database problem involving customer purchasing behavior across product categories. We are given two tables: ProductPurchases records which products each user purchased. A user may purchase multiple products, and each purchase has a quantity.

leetcodeharddatabase
LeetCode 3553 - Minimum Weighted Subgraph With the Required Paths II

We are given a weighted, undirected tree with n nodes. Because the graph is a tree, there is exactly one simple path between any two nodes.

leetcodehardarraydynamic-programmingbit-manipulationtreedepth-first-search
LeetCode 3552 - Grid Teleportation Traversal

This problem presents a 2D grid traversal scenario with obstacles and teleportation portals. You are given a matrix of characters representing cells. Empty cells '.

leetcodemediumarrayhash-tablebreadth-first-searchmatrix
LeetCode 3547 - Maximum Sum of Edge Values in a Graph

The graph is undirected, connected, and every node has degree at most 2. A connected graph where every node has degree at most 2 can only have one of two shapes: - A simple path, containing exactly n - 1 edges. - A simple cycle, containing exactly n edges.

leetcodehardmathgreedygraph-theory
LeetCode 3546 - Equal Sum Grid Partition I

This problem asks us to determine whether a rectangular grid of positive integers can be split into two parts with exactly the same sum using a single straight cut. The cut can be made in only one of two ways: - A horizontal cut between two adjacent rows.

leetcodemediumarraymatrixenumerationprefix-sum
LeetCode 3544 - Subtree Inversion Sum

This problem asks us to select a subset of nodes in a rooted tree such that each selected node triggers a subtree inversion, and inversions interact through ancestor-descendant relationships with a distance constraint.

leetcodehardarraydynamic-programmingtreedepth-first-search
LeetCode 3545 - Minimum Deletions for At Most K Distinct Characters

The problem gives us a string s containing lowercase English letters and an integer k. We are allowed to delete any characters from the string, including multiple occurrences of the same character.

leetcodeeasyhash-tablestringgreedysortingcounting
LeetCode 3542 - Minimum Operations to Convert All Elements to Zero

The problem requires us to reduce all elements of a given non-negative integer array nums to zero using the fewest number of operations. Each operation allows selecting a contiguous subarray and setting all occurrences of the minimum non-negative integer in that subarray to zero.

leetcodemediumarrayhash-tablestackgreedymonotonic-stack
LeetCode 3543 - Maximum Weighted K-Edge Path

We are given a directed acyclic graph (DAG) with n nodes and weighted directed edges. Each edge is represented as [u, v, w], meaning there is a directed edge from node u to node v with weight w. The goal is to find a path that satisfies two conditions: 1.

leetcodemediumhash-tabledynamic-programminggraph-theory
LeetCode 3540 - Minimum Time to Visit All Houses

This problem describes a set of n houses arranged in a circle. Between adjacent houses, there are two directed road systems: - forward[i] is the distance from house i to (i + 1) % n. - backward[i] is the distance from house i to (i - 1 + n) % n.

leetcodemediumarrayprefix-sum
LeetCode 3541 - Find Most Frequent Vowel and Consonant

The problem requires analyzing a string s composed of lowercase English letters and determining the sum of the maximum frequency of vowels and the maximum frequency of consonants. Vowels are defined as 'a', 'e', 'i', 'o', and 'u'. All other letters are consonants.

leetcodeeasyhash-tablestringcounting
LeetCode 3538 - Merge Operations for Minimum Travel Time

This problem presents a road of length l kilometers, segmented by n signs at strictly increasing positions, where the first sign is at the start of the road (position[0] = 0) and the last sign is at the end of the road (position[n-1] = l).

leetcodehardarraydynamic-programmingprefix-sum
LeetCode 3535 - Unit Conversion II

The input describes a collection of unit conversion relationships. Each conversion is given as: source - target with factor f meaning: 1 unit of source = f units of target The important observation is that there are exactly n - 1 conversion edges among n units, and the…

leetcodemediumarraymathdepth-first-searchbreadth-first-searchgraph-theory
LeetCode 3536 - Maximum Product of Two Digits

The problem gives us a positive integer n and asks us to find the maximum product that can be formed by multiplying any two digits that appear in the number. The input is a single integer.

leetcodeeasymathsorting
LeetCode 3533 - Concatenated Divisibility

We are given an array nums containing up to 13 positive integers and an integer k. We may reorder the numbers in any permutation. After choosing an ordering, we concatenate the decimal representations of the numbers to form a single large integer.

leetcodehardarraydynamic-programmingbit-manipulationbitmask
LeetCode 3529 - Count Cells in Overlapping Horizontal and Vertical Substrings

We are given a character matrix and a pattern string. The key observation is that the problem defines two unusual traversal orders: - A horizontal traversal reads the matrix row by row, from left to right. When a row ends, reading continues at the beginning of the next row.

leetcodemediumarraystringrolling-hashstring-matchingmatrixhash-function
LeetCode 3532 - Path Existence Queries in a Graph I

This problem defines an undirected graph implicitly through a sorted array nums. Each index in nums represents a graph node. Two nodes i and j are connected by an edge whenever: We are then given many connectivity queries.

leetcodemediumarrayhash-tablebinary-searchunion-findgraph-theory
LeetCode 3530 - Maximum Profit from Valid Topological Order in DAG

The problem requires computing the maximum possible profit achievable by processing nodes of a Directed Acyclic Graph (DAG) in a valid topological order.

leetcodehardarraydynamic-programmingbit-manipulationgraph-theorytopological-sortbitmask
LeetCode 3527 - Find the Most Common Response

This problem gives us a two dimensional array of strings called responses. Each responses[i] represents all survey responses collected on the ith day. A response is simply a string such as "good", "ok", or "bad".

leetcodemediumarrayhash-tablestringcounting
LeetCode 3525 - Find X Value of Array II

For each query, two things happen in order. First, we permanently update one element of nums: This modification remains in effect for all future queries. Second, we conceptually remove the prefix nums[0..start-1].

leetcodehardarraymathsegment-tree
LeetCode 3524 - Find X Value of Array I

The operation described in the problem may initially look unusual, but it is actually equivalent to choosing a non-empty contiguous subarray. When we remove a prefix and a suffix that do not overlap, the elements left behind form a contiguous segment of the original array.

leetcodemediumarraymathdynamic-programming
LeetCode 3523 - Make Array Non-decreasing

The problem asks us to transform an integer array nums into a non-decreasing array by performing zero or more operations, where an operation consists of selecting a contiguous subarray and replacing it with its maximum value.

leetcodemediumarraystackgreedymonotonic-stack
LeetCode 3518 - Smallest Palindromic Rearrangement II

We are given a string s that is guaranteed to already be a palindrome. We may rearrange its characters, but the final rearranged string must also be a palindrome.

leetcodehardhash-tablemathstringcombinatoricscounting
LeetCode 3515 - Shortest Path in a Weighted Tree

We are given a weighted tree with n nodes, rooted at node 1. A tree has exactly one simple path between any pair of nodes. Since the tree is rooted at node 1, every node has a unique path from the root.

leetcodehardarraytreedepth-first-searchbinary-indexed-treesegment-tree
LeetCode 3514 - Number of Unique XOR Triplets II

We are given an integer array nums, and we must consider every triplet of indices (i, j, k) such that i <= j <= k. For each valid triplet, we compute: where ⊕ denotes the bitwise XOR operation. The goal is not to count triplets.

leetcodemediumarraymathbit-manipulationenumeration
LeetCode 3511 - Make a Positive Array

Before diving into the detailed solution guide, I want to clarify one subtle point: the problem specifies that all subarrays with more than two elements must have a positive sum. This means the smallest subarray we need to consider is of length 3.

leetcodemediumarraygreedyprefix-sum
LeetCode 3513 - Number of Unique XOR Triplets I

The problem asks us to determine the number of unique values that can result from taking the XOR of three elements in a given array nums, where the triplets (i, j, k) must satisfy i <= j <= k.

leetcodemediumarraymathbit-manipulation
LeetCode 3517 - Smallest Palindromic Rearrangement I

The problem asks us to take a palindromic string s and return its lexicographically smallest palindromic permutation.

leetcodemediumstringsortingcounting-sort
LeetCode 3516 - Find Closest Person

This problem gives us three integers, x, y, and z, representing the positions of three people on a one-dimensional number line. Person 1 starts at position x, Person 2 starts at position y, and Person 3 remains stationary at position z.

leetcodeeasymath
LeetCode 3512 - Minimum Operations to Make Array Sum Divisible by K

The problem gives us an integer array nums and an integer k. We are allowed to repeatedly perform one operation: choose any index i and decrease nums[i] by exactly 1.

leetcodeeasyarraymath
LeetCode 3510 - Minimum Pair Removal to Sort Array II

We are given an array nums. The operation is highly constrained: 1. Among all adjacent pairs, find the pair with the minimum sum. 2. If multiple adjacent pairs have the same minimum sum, choose the leftmost one. 3. Replace those two elements with their sum.

leetcodehardarrayhash-tablelinked-listheap-(priority-queue)simulationdoubly-linked-listordered-set
LeetCode 3509 - Maximum Product of Subsequences With an Alternating Sum Equal to K

The problem asks us to find a subsequence of a given integer array nums such that the alternating sum of the subsequence equals a target integer k, while maximizing the product of the numbers in that subsequence without exceeding a given limit.

leetcodehardarrayhash-tabledynamic-programming
LeetCode 3508 - Implement Router

The problem is asking us to design a Router data structure to manage network packets efficiently under memory constraints. Each packet has three attributes: source, destination, and timestamp. The router has a memory limit, meaning it can store only a fixed number of packets.

leetcodemediumarrayhash-tablebinary-searchdesignqueueordered-set
LeetCode 3507 - Minimum Pair Removal to Sort Array I

We are given an array nums. At any step, we are not free to choose any adjacent pair. Instead, the operation is completely determined by the current state of the array: 1. Find the adjacent pair whose sum is the smallest. 2.

leetcodeeasyarrayhash-tablelinked-listheap-(priority-queue)simulationdoubly-linked-listordered-set
LeetCode 3503 - Longest Palindrome After Substring Concatenation I

We are given two strings, s and t, and we are allowed to choose: 1. Any substring of s, including the empty string. 2. Any substring of t, including the empty string. The chosen substring from s must come first, and the chosen substring from t must come second.

leetcodemediumtwo-pointersstringdynamic-programmingenumeration
LeetCode 3497 - Analyze Subscription Conversion

This is a SQL aggregation problem where we need to analyze user subscription behavior and return statistics only for users who successfully converted from a free trial to a paid subscription. The UserActivity table contains one row per user, per day, per activity type.

leetcodemediumdatabase
LeetCode 3493 - Properties Graph

The problem asks us to model a 2D array of integers, called properties, as an undirected graph. Each row of the array corresponds to a node in the graph. Two nodes are connected if the number of distinct integers they share is at least k.

leetcodemediumarrayhash-tabledepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 3499 - Maximize Active Section with Trade I

The problem gives a binary string s representing sections of a system, where '1' indicates an active section and '0' indicates an inactive section. We are allowed at most one trade to maximize the number of active sections.

leetcodemediumstringenumeration
LeetCode 3501 - Maximize Active Section with Trade II

The problem presents a binary string s where each character represents an active ('1') or inactive ('0') section. For each query, which specifies a substring of s, we are asked to determine the maximum number of active sections after performing at most one trade operation.

leetcodehardarraystringbinary-searchsegment-tree
LeetCode 3500 - Minimum Cost to Divide Array Into Subarrays

This problem asks us to partition an array nums into contiguous subarrays, where each subarray contributes a weighted cost to the total. The cost for a subarray nums[l..

leetcodehardarraydynamic-programmingprefix-sum
LeetCode 3498 - Reverse Degree of a String

The problem asks us to compute a special value called the reverse degree of a string. Normally, letters are assigned positions in the alphabet as: - 'a' = 1 - 'b' = 2 - ... - 'z' = 26 However, this problem uses the reversed alphabet order, where: - 'a' = 26 - 'b' = 25 - ...

leetcodeeasystringsimulation
LeetCode 3492 - Maximum Containers on a Ship

This problem describes a cargo ship with an n × n deck. Since each cell on the deck can hold exactly one container, the deck has a total capacity of: physical container positions. Every container has the same weight, w. The ship also has a maximum total weight limit, maxWeight.

leetcodeeasymath