brain

tamnd's digital brain — notes, problems, research

41835 notes

LeetCode 3706 - Maximum Distance Between Unequal Words in Array II

We are given an array of strings called words. Our goal is to find two different indices i and j such that the strings at those positions are different, meaning words[i] != words[j].

leetcodemediumarraystring
LeetCode 3705 - Find Golden Hour Customers

This problem asks us to identify "golden hour customers" from a restaurant's order history. A golden hour customer is defined as someone who consistently orders during peak hours and maintains high satisfaction.

leetcodemedium
LeetCode 3697 - Compute Decimal Representation

This problem asks us to decompose a positive integer n into the fewest possible base-10 components, where a base-10 component is defined as a single digit (1-9) multiplied by a power of 10. Essentially, we are breaking n down into its decimal place contributions.

leetcodeeasyarraymath
LeetCode 3695 - Maximize Alternating Sum Using Swaps

We are given an array nums and a list of allowed swap operations. The alternating sum of an array is defined as: Elements at even indices contribute positively, while elements at odd indices contribute negatively.

leetcodehardarraygreedyunion-findsorting
LeetCode 3693 - Climbing Stairs II

This problem is an extension of the classic "climbing stairs" dynamic programming problem but with more complex jump costs. You are given a staircase with n + 1 steps, numbered from 0 to n. Each intermediate step i (1-indexed) has an associated cost costs[i].

leetcodemediumarraydynamic-programming
LeetCode 3694 - Distinct Points Reachable After Substring Removal

We are given a movement string s consisting of the four directions: - U increases the y-coordinate by 1. - D decreases the y-coordinate by 1. - L decreases the x-coordinate by 1. - R increases the x-coordinate by 1.

leetcodemediumhash-tablestringsliding-windowprefix-sum
LeetCode 3689 - Maximum Total Subarray Value I

The problem asks us to select exactly k non-empty subarrays from a given integer array nums, where subarrays may overlap and can even be identical. For each chosen subarray nums[l..

leetcodemediumarraygreedy
LeetCode 3686 - Number of Stable Subsequences

The problem asks us to count how many subsequences of a given integer array are stable, where stability is defined by a constraint on parity patterns inside the subsequence itself.

leetcodehardarraydynamic-programming
LeetCode 3688 - Bitwise OR of Even Numbers in an Array

This problem asks us to compute the bitwise OR of all even numbers in a given integer array nums. A number is considered even if it is divisible by 2, meaning its least significant bit is 0.

leetcodeeasyarraybit-manipulationsimulation
LeetCode 3683 - Earliest Time to Finish One Task

The problem gives us a list of tasks, where each task is represented by two integers: - si, the time when the task starts. - ti, the amount of time required to complete the task.

leetcodeeasyarray
LeetCode 3684 - Maximize Sum of At Most K Distinct Elements

This problem requires selecting at most k distinct elements from a given array of positive integers nums such that their sum is maximized. The result must be returned as a list sorted in strictly descending order.

leetcodeeasyarrayhash-tablegreedysorting
LeetCode 3677 - Count Binary Palindromic Numbers

We are given a non-negative integer n and asked to count how many integers k in the range [0, n] have a binary representation that is a palindrome when written without leading zeros.

leetcodehardmathbit-manipulation
LeetCode 3682 - Minimum Index Sum of Common Elements

This problem is asking us to identify the smallest sum of indices from two equal-length arrays, nums1 and nums2, such that the elements at those indices are equal. Formally, we want a pair (i, j) where nums1[i] == nums2[j], and we want the minimum value of i + j.

leetcodemediumarrayhash-table
LeetCode 3680 - Generate Schedule

The problem is asking us to generate a round-robin style schedule for n teams, where each team plays every other team exactly twice, once at home and once away. Each day in the schedule can host exactly one match, and a team is not allowed to play on consecutive days.

leetcodemediumarraymathgreedy
LeetCode 3676 - Count Bowl Subarrays

The problem asks us to count how many subarrays in an array of distinct integers satisfy a specific “bowl” condition. A subarray nums[l...

leetcodemediumarraystackmonotonic-stack
LeetCode 3674 - Minimum Operations to Equalize Array

Let's go step by step and produce a fully detailed, reference-style solution guide for LeetCode 3674 following your requested formatting. The problem asks us to make all elements of an integer array nums equal using the minimum number of operations.

leetcodeeasyarraybit-manipulationbrainteaser
LeetCode 3667 - Sort Array By Absolute Value

The problem asks us to reorder an integer array such that the elements are sorted in non-decreasing order of their absolute values.

leetcodeeasyarraymathtwo-pointerssorting
LeetCode 3668 - Restore Finishing Order

This problem gives us two arrays: - order, which represents the finishing order of all participants in a race. - friends, which contains the IDs of our friends. The array order is a permutation of the integers from 1 to n, meaning every participant appears exactly once.

leetcodeeasyarrayhash-table
LeetCode 3665 - Twisted Mirror Path Count

This problem asks us to count all unique paths from the top-left corner (0, 0) to the bottom-right corner (m - 1, n - 1) of a binary grid where certain cells contain mirrors.

leetcodemediumarraydynamic-programmingmatrix
LeetCode 3664 - Two-Letter Card Game

Each card consists of exactly two lowercase letters. A card is only relevant if it contains the given letter x somewhere in its two positions. During the game, we repeatedly select two cards that satisfy two conditions: 1. Both cards contain the letter x. 2.

leetcodemediumarrayhash-tablestringcountingenumeration
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