brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 2286 - Booking Concert Tickets in Groups

The problem asks us to design a ticket reservation system for a concert hall. The hall contains n rows, and each row contains exactly m seats. Seats in every row are numbered from left to right starting at 0.

leetcodehardbinary-searchdesignbinary-indexed-treesegment-tree
LeetCode 2834 - Find the Minimum Possible Sum of a Beautiful Array

We are given two positive integers, n and target. We need to construct an array of exactly n distinct positive integers such that no two different elements add up to target. Among all arrays satisfying these conditions, we want the one with the smallest possible sum.

leetcodemediummathgreedy
CF 141C - Queue

Each person remembers a single number, how many taller people stood before them in the queue. We no longer know either the original order or the actual heights. The task is to reconstruct any valid queue order together with heights that satisfy every person's remembered value.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortings
CF 248D - Sweets for Everyone!

We are given a one-dimensional street made of n consecutive sections. Each section is either a house that must receive exactly one kilogram of sweets, a shop that can provide at most one kilogram of sweets, or empty space that only matters for movement.

codeforcescompetitive-programmingbinary-searchgreedyimplementation
LeetCode 2897 - Apply Operations on Array to Maximize Sum of Squares

The problem presents an integer array nums and a positive integer k. You can perform a bitwise operation on any two distinct elements of the array any number of times.

leetcodehardarrayhash-tablegreedybit-manipulation
LeetCode 3205 - Maximum Array Hopping Score I

The problem asks us to calculate the maximum score achievable by hopping through an array from the first element to the last. You start at index 0, and at each step, you can jump to any subsequent index j i. When you jump, you accumulate a score of (j - i) nums[j].

leetcodemediumarraydynamic-programmingstackgreedymonotonic-stack
LeetCode 2565 - Subsequence With the Minimum Score

This problem is long and deserves a detailed explanation to do it properly, especially with all requested sections, worked examples, Python and Go implementations, proof sketch, comprehensive tests, and edge cases.

leetcodehardtwo-pointersstringbinary-search
LeetCode 2125 - Number of Laser Beams in a Bank

The problem describes a bank floor plan as a binary matrix, represented by an array of strings. Each row corresponds to one row in the bank, and each character in the string represents a cell.

leetcodemediumarraymathstringmatrix
CF 144A - Arrival of the General

We have a line of soldiers, each with a height. The general only cares about two positions in the lineup. The tallest soldier must stand at the very front, and the shortest soldier must stand at the very end. The order of everyone else is irrelevant.

codeforcescompetitive-programmingimplementation
LeetCode 2853 - Highest Salaries Difference

The problem provides a database table named Salaries with three columns: | Column | Meaning | | --- | --- | | empname | Employee name | | department | Employee department | | salary | Employee salary | The combination of (empname, department) is unique, meaning there are no…

leetcodeeasydatabase
LeetCode 2596 - Check Knight Tour Configuration

The problem gives us an n x n matrix called grid, where every number from 0 to n n - 1 appears exactly once. Each value represents the order in which a knight visited that cell during a tour of the chessboard. A knight in chess moves in an L-shape.

leetcodemediumarraydepth-first-searchbreadth-first-searchmatrixsimulation
LeetCode 3344 - Maximum Sized Array

We are given a non-negative integer s and need to determine the largest possible dimension n of a three-dimensional array A. The array has dimensions n × n × n, and every element is defined as: where | denotes the bitwise OR operation.

leetcodemediumbinary-searchbit-manipulation
LeetCode 2489 - Number of Substrings With Fixed Ratio

The problem gives us a binary string s, along with two coprime integers num1 and num2. We need to count how many non-empty substrings contain 0s and 1s in the exact ratio num1 : num2.

leetcodemediumhash-tablemathstringprefix-sum
LeetCode 2838 - Maximum Coins Heroes Can Collect

This problem gives us three arrays: - heroes, where heroes[i] represents the power of the ith hero. - monsters, where monsters[j] represents the power of the jth monster. - coins, where coins[j] represents the reward obtained for defeating the jth monster.

leetcodemediumarraytwo-pointersbinary-searchsortingprefix-sum
LeetCode 2050 - Parallel Courses III

The problem asks us to determine the minimum number of months required to complete all courses given prerequisite relationships and the time each course takes. Each course is labeled from 1 to n, and relations describes which courses must be completed before others.

leetcodehardarraydynamic-programminggraph-theorytopological-sort
LeetCode 3364 - Minimum Positive Sum Subarray

The problem asks us to find the smallest positive sum among all subarrays whose lengths fall within a given range [l, r]. A subarray is a contiguous section of the array. We are allowed to choose any non-empty contiguous segment as long as: 1.

leetcodeeasyarraysliding-windowprefix-sum
LeetCode 3199 - Count Triplets with Even XOR Set Bits I

The problem gives us three integer arrays, a, b, and c. We must count how many triplets (a[i], b[j], c[k]) produce a bitwise XOR result with an even number of set bits. A set bit is a bit equal to 1 in the binary representation of a number.

leetcodeeasyarraybit-manipulation
LeetCode 2359 - Find Closest Node to Given Two Nodes

The problem asks us to find a node in a directed graph with a very specific property: it must be reachable from two given starting nodes (node1 and node2) such that the maximum distance from either starting node to this node is minimized.

leetcodemediumdepth-first-searchgraph-theory
LeetCode 2409 - Count Days Spent Together

The problem asks us to calculate the number of days Alice and Bob spend together in Rome based on their respective arrival and departure dates. Each date is represented as a string in the format "MM-DD".

leetcodeeasymathstring
LeetCode 2968 - Apply Operations to Maximize Frequency Score

This problem asks us to maximize the frequency of the most common value in an array after performing at most k operations. Each operation allows us to choose any element and either increase or decrease it by exactly 1.

leetcodehardarraybinary-searchsliding-windowsortingprefix-sum
LeetCode 1916 - Count Ways to Build Rooms in an Ant Colony

The problem asks us to count the number of valid ways to sequentially build all rooms in an ant colony, given a dependency tree that dictates which rooms must be built before others. Each room i has a predecessor prevRoom[i] that must be built before i.

leetcodehardarraymathdynamic-programmingtreedepth-first-searchgraph-theorytopological-sortcombinatorics
LeetCode 2049 - Count Nodes With the Highest Score

The input describes a rooted binary tree using a parent array. Every node is identified by an integer from 0 to n - 1, and parents[i] tells us which node is the parent of node i. The root node is always 0, so its parent is -1. The goal is to compute a score for every node.

leetcodemediumarraytreedepth-first-searchbinary-tree
LeetCode 2087 - Minimum Cost Homecoming of a Robot in a Grid

The problem gives us a robot located on a two dimensional grid. The robot starts at startPos = [startrow, startcol] and wants to reach homePos = [homerow, homecol]. The robot can move one cell at a time in four directions: up, down, left, and right.

leetcodemediumarraygreedy
LeetCode 2874 - Maximum Value of an Ordered Triplet II

The problem gives us a 0-indexed integer array nums and asks us to find the maximum possible value of: subject to the constraint: In other words, we must choose three indices in increasing order.

leetcodemediumarray
CF 186B - Growing Mushrooms

We have a mushroom-growing contest with two phases separated by a break. Each participant has two speeds, and the problem is that we do not know the order they will use them. During the first phase of length t1, mushrooms grow at one speed.

codeforcescompetitive-programminggreedysortings
LeetCode 2989 - Class Performance

The problem asks us to calculate the difference between the highest and lowest total scores among students in a class. Each student has three assignment scores, and the total score is simply the sum of these three values.

leetcodemediumdatabase
LeetCode 3355 - Zero Array Transformation I

The problem asks whether it is possible to transform a given integer array nums into a Zero Array, where all elements are zero, using a series of decrement operations defined by queries.

leetcodemediumarrayprefix-sum
LeetCode 2895 - Minimum Processing Time

This problem gives us two arrays: - processorTime, where each value represents the time when a processor becomes available - tasks, where each value represents how long a task takes to execute Each processor has exactly 4 cores, and each core can execute exactly one task.

leetcodemediumarraygreedysorting
LeetCode 2453 - Destroy Sequential Targets

The problem presents a scenario where we have a list of positive integers nums representing targets placed on a number line. We also have an integer space representing the step interval of a machine.

leetcodemediumarrayhash-tablecounting
LeetCode 2745 - Construct the Longest New String

The problem gives us three types of fixed two-character strings: - "AA" appears x times - "BB" appears y times - "AB" appears z times We may choose any subset of these strings and concatenate them in any order.

leetcodemediummathdynamic-programminggreedybrainteaser
CF 203B - Game on Paper

We have an n × n grid that starts completely white. Cells are painted black one by one, and every move paints a different cell. After each move, we want to know whether the board already contains a completely black 3 × 3 square.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 3051 - Find Candidates for Data Scientist Position

You included two different LeetCode problems with conflicting templates. The second problem appears to be the one you want covered: LeetCode 3051 - Find Candidates for Data Scientist Position (Database) However, the required sections still reference Python and Go solutions…

leetcodeeasydatabase
LeetCode 2285 - Maximum Total Importance of Roads

Here is the complete technical solution guide for LeetCode 2285 following your requested format and level of detail: The problem gives you n cities, numbered from 0 to n - 1, and a list of bidirectional roads connecting pairs of cities.

leetcodemediumgreedygraph-theorysortingheap-(priority-queue)
LeetCode 3056 - Snaps Analysis

The problem requires calculating the percentage of time each age group spends on two types of snap activities: sending and opening. We are given two tables: Activities and Age.

leetcodemediumdatabase
LeetCode 3356 - Zero Array Transformation II

The problem asks us to determine the minimum number of sequential queries required to transform an array nums into a Zero Array, where all elements are zero. Each query specifies a subarray [li, ri] and a value vali.

leetcodemediumarraytwo-pointersbinary-searchprefix-sum
LeetCode 2894 - Divisible and Non-divisible Sums Difference

This problem gives us two positive integers, n and m. We need to examine every integer in the inclusive range [1, n] and separate the numbers into two groups based on divisibility by m. The first group contains all numbers that are not divisible by m.

leetcodeeasymath
LeetCode 3089 - Find Bursty Behavior

The problem asks us to identify users who demonstrate "bursty behavior" in their posting patterns during February 2024.

leetcodemediumdatabase
CF 203E - Transportation

We are tasked with transporting robots across a fixed distance using a limited fuel supply. Each robot has three characteristics: the number of other robots it can carry, the amount of fuel it consumes to move on its own, and the maximum distance it can travel.

codeforcescompetitive-programminggreedysortingstwo-pointers
LeetCode 1987 - Number of Unique Good Subsequences

The problem asks us to count how many distinct subsequences of a binary string are considered “good.” A subsequence is any sequence formed by deleting zero or more characters without changing the relative order of remaining characters.

leetcodehardstringdynamic-programming
LeetCode 2556 - Disconnect Path in a Binary Matrix by at Most One Flip

The problem is asking whether it is possible to disconnect a path from the top-left corner (0, 0) to the bottom-right corner (m - 1, n - 1) in a binary matrix by flipping at most one cell from 1 to 0 or 0 to 1. A path only allows moves down or right into cells containing 1.

leetcodemediumarraydynamic-programmingdepth-first-searchbreadth-first-searchmatrix
LeetCode 3187 - Peaks in Array

The problem asks us to process two kinds of operations on an integer array: 1. Query how many peaks exist inside a subarray. 2. Update a single element in the array. A peak is defined as an element that is strictly greater than both its immediate neighbors.

leetcodehardarraybinary-indexed-treesegment-tree
CF 142E - Help Greg the Dwarf 2

We are asked to find the shortest distance between two points on a cone, where the cone has a circular base of radius r and height h, and the points may lie anywhere on the cone's lateral surface or the base.

codeforcescompetitive-programminggeometry
LeetCode 2802 - Find The K-th Lucky Number

This problem asks us to find the k-th lucky number, where a lucky number is defined as an integer consisting only of the digits 4 and 7. For example, the sequence of lucky numbers in increasing order starts as 4, 7, 44, 47, 74, 77, 444, and so on.

leetcodemediummathstringbit-manipulation
LeetCode 3213 - Construct String with Minimum Cost

The problem asks us to construct a target string target by repeatedly appending strings from a given array words, where each word has an associated cost in costs. The goal is to determine the minimum total cost to construct target exactly.

leetcodehardarraystringdynamic-programmingsuffix-array
LeetCode 3216 - Lexicographically Smallest String After a Swap

The problem requires transforming a string of digits into its lexicographically smallest form by performing at most one swap between adjacent digits of the same parity. Here, parity refers to whether a digit is even or odd.

leetcodeeasystringgreedy
LeetCode 2069 - Walking Robot Simulation II

The problem describes a simulation of a robot moving on a rectangular grid defined by width x height. The robot starts at the bottom-left corner (0, 0) facing East and moves in discrete steps.

leetcodemediumdesignsimulation
LeetCode 2645 - Minimum Additions to Make Valid String

This problem asks us to determine the minimum number of insertions needed to transform a given string word into a valid string. A valid string is defined as one that can be formed by concatenating the sequence "abc" one or more times.

leetcodemediumstringdynamic-programmingstackgreedy
LeetCode 2973 - Find Number of Coins to Place in Tree Nodes

The problem gives us a tree with n nodes labeled from 0 to n - 1. The tree is undirected and rooted at node 0. The tree structure is described by the edges array, where each edge [a, b] connects nodes a and b. Each node also has an associated cost, given in the cost array.

leetcodeharddynamic-programmingtreedepth-first-searchsortingheap-(priority-queue)
LeetCode 2709 - Greatest Common Divisor Traversal

Understood. I will provide the complete, detailed reference guide for LeetCode 2702 - Minimum Operations to Make Numbers Non-positive, following your formatting rules exactly. The problem provides a 0-indexed integer array nums and two integers x and y.

leetcodehardarraymathunion-findnumber-theory
CF 153C - Caesar Cipher

We are asked to implement a Caesar cipher on an input string of uppercase Latin letters. Conceptually, this means each letter is shifted forward in the alphabet by a fixed number of positions, denoted by k. If the shift goes past 'Z', it wraps around to 'A'.

codeforcescompetitive-programming*special
LeetCode 2153 - The Number of Passengers in Each Bus II

The problem describes a simulation of passengers arriving at a bus station and buses arriving to pick them up. Each bus has a unique ID, an arrival time, and a limited capacity. Each passenger has a unique ID and an arrival time.

leetcodeharddatabase
LeetCode 2476 - Closest Nodes Queries in a Binary Search Tree

The problem gives us the root of a binary search tree, abbreviated as BST, along with a list of query values. For every query, we must determine two numbers: - The largest value in the BST that is less than or equal to the query.

leetcodemediumarraybinary-searchtreedepth-first-searchbinary-search-treebinary-tree
LeetCode 2094 - Finding 3-Digit Even Numbers

The problem gives us an array named digits, where every element is a single decimal digit from 0 to 9. We must use exactly three elements from this array to build valid three digit integers.

leetcodeeasyarrayhash-tablerecursionsortingenumeration
CF 142B - Help General

We have an n × m chessboard-like grid, and we want to place as many soldiers as possible. Two soldiers conflict if the squared Euclidean distance between their cells is exactly 5. The only integer pairs whose squared distance equals 5 are (1, 2) and (2, 1) up to sign.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
LeetCode 3243 - Shortest Distance After Road Addition Queries I

We are given n cities labeled from 0 to n - 1. Initially, the graph forms a simple directed chain: - 0 - 1 - 1 - 2 - 2 - 3 - ...

leetcodemediumarraybreadth-first-searchgraph-theory
LeetCode 2393 - Count Strictly Increasing Subarrays

The problem asks us to count all strictly increasing subarrays in a given array nums of positive integers. A strictly increasing subarray is a contiguous sequence of numbers where each element is strictly larger than the previous one.

leetcodemediumarraymathdynamic-programming
LeetCode 2322 - Minimum Score After Removals on a Tree

That is a long, multi-section technical guide with code, worked examples, test cases, and detailed explanations. I can provide the full reference document, but it will be quite large.

leetcodehardarraybit-manipulationtreedepth-first-search
LeetCode 2950 - Number of Divisible Substrings

The problem asks us to analyze a given string word where each lowercase English letter is mapped to a digit according to a classic phone keypad scheme.

leetcodemediumhash-tablestringcountingprefix-sum
LeetCode 3157 - Find the Level of Tree with Minimum Sum

The problem gives us the root of a binary tree, where every node contains a positive integer value. Our task is to determine which level of the tree has the smallest sum of node values.

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-tree
CF 137B - Permutation

We are given an array of $n$ integers, each between 1 and 5000, and we are asked to transform this array into a permutation of the numbers from 1 to $n$. A permutation is a sequence where each integer from 1 to $n$ appears exactly once.

codeforcescompetitive-programminggreedy
LeetCode 2862 - Maximum Element-Sum of a Complete Subset of Indices

The array nums is 1-indexed, meaning the first element corresponds to index 1, the second element corresponds to index 2, and so on. We want to select a subset of indices such that for every pair of selected indices i and j, the product i j is a perfect square.

leetcodehardarraymathnumber-theory
LeetCode 3221 - Maximum Array Hopping Score II

The problem gives us an integer array nums, where each position represents a possible location we can stand on. We always begin at index 0, and we must eventually reach the last index of the array. From any index i, we are allowed to jump to any later index j where j i.

leetcodemediumarraystackgreedymonotonic-stack
LeetCode 2507 - Smallest Value After Replacing With Sum of Prime Factors

The problem asks us to repeatedly replace a number n with the sum of its prime factors until it reaches the smallest value it can take.

leetcodemediummathsimulationnumber-theory
LeetCode 2555 - Maximize Win From Two Segments

The problem gives us a sorted array prizePositions, where each value represents the position of a prize on the X-axis. Multiple prizes may exist at the same position. We are also given an integer k. We may choose exactly two segments on the number line.

leetcodemediumarraybinary-searchsliding-window
LeetCode 2652 - Sum Multiples

The problem requires calculating the sum of all integers from 1 up to a given positive integer n that are divisible by 3, 5, or 7. In simpler terms, we need to consider each number in the range [1, n] and check if it is a multiple of any of these three numbers.

leetcodeeasymath
CF 253B - Physics Practical

We are given a list of measurement results from a physics experiment. Vasya wants to keep as many measurements as possible, but the remaining set must satisfy one condition: the largest remaining value cannot be more than twice the smallest remaining value.

codeforcescompetitive-programmingbinary-searchdpsortingstwo-pointers
LeetCode 2969 - Minimum Number of Coins for Fruits II

The problem asks us to determine the minimum number of coins required to purchase all fruits in a market, given a special offer. You are provided with a 1-indexed array prices, where prices[i] denotes the number of coins needed to buy the ith fruit.

leetcodehardarraydynamic-programmingqueueheap-(priority-queue)monotonic-queue
LeetCode 2660 - Determine the Winner of a Bowling Game

The problem describes a simplified scoring system for a bowling game between two players. Each player has an array representing the number of pins hit in each turn, and there are exactly n turns.

leetcodeeasyarraysimulation
LeetCode 2714 - Find Shortest Path with K Hops

This problem gives us an undirected weighted graph with n nodes and a list of weighted edges. Each edge connects two nodes and has a positive weight. We are also given a source node s, a destination node d, and an integer k.

leetcodehardgraph-theoryheap-(priority-queue)shortest-path
LeetCode 2097 - Valid Arrangement of Pairs

This problem gives us a list of directed pairs, where each pair [starti, endi] represents a directed edge from starti to endi. We must rearrange all pairs so that adjacent pairs connect correctly.

leetcodehardarraydepth-first-searchgraph-theoryeulerian-circuit
LeetCode 3005 - Count Elements With Maximum Frequency

The problem gives us an integer array nums, where every value is positive. We need to determine which elements appear most frequently, then return the total number of occurrences contributed by all such elements.

leetcodeeasyarrayhash-tablecounting
LeetCode 1994 - The Number of Good Subsets

This problem asks us to count how many subsets of the input array have a product that can be written as a multiplication of distinct prime numbers. The phrase "distinct prime numbers" is the key restriction.

leetcodehardarrayhash-tablemathdynamic-programmingbit-manipulationcountingnumber-theorybitmask
CF 158C - Cd and pwd commands

We need to simulate a tiny shell that supports only two commands. The command cd path changes the current directory. The path may be absolute, meaning it starts from the root /, or relative, meaning it starts from the current directory. Inside a path, the token ..

codeforcescompetitive-programming*specialdata-structuresimplementation
LeetCode 2524 - Maximum Frequency Score of a Subarray

The problem asks us to compute the maximum frequency score among all contiguous subarrays of length k from a given integer array nums. A frequency score is defined as the sum of each distinct element raised to the power of its frequency within the subarray, taken modulo 10^9 + 7.

leetcodehardarrayhash-tablemathstacksliding-window
LeetCode 2557 - Maximum Number of Integers to Choose From a Range II

The problem is asking to select the maximum number of integers from the range [1, n] under several constraints. First, integers in the banned array cannot be chosen. Second, each integer can be chosen at most once. Third, the sum of all chosen integers must not exceed maxSum.

leetcodemediumarraybinary-searchgreedysorting
CF 146A - Lucky Ticket

We are asked to determine whether a ticket number is lucky. A lucky ticket number satisfies two conditions simultaneously. First, every digit of the number must be either 4 or 7.

codeforcescompetitive-programmingimplementation
LeetCode 2922 - Market Analysis III

The problem asks us to analyze three relational tables: Users, Items, and Orders. Each user (seller) has a favorite brand, each item has a brand, and orders record which seller sold which item on which date.

leetcodemediumdatabase
CF 192B - Walking in the Rain

We are asked to determine the number of days the opposition can walk along a boulevard of tiles before it becomes impossible due to the tiles being destroyed by rain. Each tile has a durability measured in days.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 2946 - Matrix Similarity After Cyclic Shifts

This problem asks us to determine whether a matrix remains identical to its original form after applying a specific cyclic shifting operation exactly k times. We are given an m x n integer matrix mat, where m is the number of rows and n is the number of columns.

leetcodeeasyarraymathmatrixsimulation
CF 140C - New Year Snowmen

We are given a collection of snowballs, each with a specific radius, and our goal is to assemble as many snowmen as possible using these snowballs. Each snowman must be made of exactly three snowballs, and each of those three must have a distinct radius.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedy
LeetCode 3219 - Minimum Cost for Cutting Cake II

We are given an m x n rectangular cake and need to divide it completely into 1 x 1 pieces. The cake can be cut along predefined horizontal and vertical lines.

leetcodehardarraygreedysorting
CF 205B - Little Elephant and Sorting

We are given an array of integers, and one operation consists of choosing a contiguous segment and increasing every element inside that segment by exactly one. We may repeat this operation any number of times.

codeforcescompetitive-programmingbrute-forcegreedy
LeetCode 2372 - Calculate the Influence of Each Salesperson

This problem asks us to calculate the total sales value generated by the customers assigned to each salesperson. We are given three database tables: The Salesperson table contains the list of salespeople. Each salesperson has a unique salespersonid and a name.

leetcodemediumdatabase
CF 213A - Game

We are given a game split into n parts. Each part must be completed on a specific computer, and some parts depend on others, forming a dependency graph without cycles. Rubik can start at any computer and spends exactly one hour to complete a part.

codeforcescompetitive-programmingdfs-and-similargreedy
LeetCode 2180 - Count Integers With Even Digit Sum

The problem asks us to count all positive integers less than or equal to a given number num such that the sum of their digits is even. In other words, we are asked to evaluate each integer 1 through num, compute the sum of its digits, and check whether that sum is divisible by 2.

leetcodeeasymathsimulation
LeetCode 3083 - Existence of a Substring in a String and Its Reverse

This is a Type B, “Prove that” problem. The statement to prove is: Among all triangles determined by 100 points in general position, at most 70% are acute. The proposed proof attempts to establish a universal upper bound on the number of acute triangles.

leetcodeeasyhash-tablestring
LeetCode 1969 - Minimum Non-Zero Product of the Array Elements

The problem gives us an integer p and defines an array containing every number from 1 to 2^p - 1. Each number is represented in binary using exactly p bits. We are allowed to repeatedly perform a special operation.

leetcodemediummathgreedyrecursion
LeetCode 2931 - Maximum Spending After Buying Items

We are given an m × n matrix values where each row represents a shop and each column represents an item in that shop. The important property is that every row is sorted in non-increasing order: When buying from a shop, we are not allowed to choose any arbitrary item.

leetcodehardarraygreedysortingheap-(priority-queue)matrix
LeetCode 2960 - Count Tested Devices After Test Operations

This problem asks us to simulate a sequence of device tests based on battery percentages. We are given a 0-indexed integer array batteryPercentages, where each element represents the current battery level of a device.

leetcodeeasyarraysimulationcounting
LeetCode 3290 - Maximum Multiplication Score

This problem gives us two integer arrays: - a, which always has exactly 4 elements. - b, which has length at least 4 and can be as large as 100,000. We must select exactly four indices from b: The score obtained from such a selection is: Our goal is to maximize this score.

leetcodemediumarraydynamic-programming
LeetCode 2521 - Distinct Prime Factors of Product of Array

The problem asks us to compute the number of distinct prime factors in the product of an array of positive integers, nums.

leetcodemediumarrayhash-tablemathnumber-theory
LeetCode 2479 - Maximum XOR of Two Non-Overlapping Subtrees

This problem gives us a rooted tree with n nodes, rooted at node 0. Every node has a numeric value, and the sum of a subtree is defined as the sum of all node values inside that subtree, including the root of the subtree and all descendants.

leetcodehardtreedepth-first-searchgraph-theorytrie
LeetCode 3269 - Constructing Two Increasing Arrays

We are given two binary arrays, nums1 and nums2. Each element is either 0 or 1. We must replace every value with a positive integer according to its parity: - Every 0 must become an even positive integer. - Every 1 must become an odd positive integer.

leetcodehardarraydynamic-programming
LeetCode 3342 - Find Minimum Time to Reach Last Room II

This problem describes a dungeon represented as an n x m grid of rooms, where each room has a constraint on the earliest time you can enter it, given by the 2D array moveTime.

leetcodemediumarraygraph-theoryheap-(priority-queue)matrixshortest-path
LeetCode 1858 - Longest Word With All Prefixes

The problem gives us an array of lowercase strings called words. We need to find the longest word such that every prefix of that word also exists in the array. A prefix means the string formed by taking characters from the beginning of the word.

leetcodemediumarraystringdepth-first-searchtrie
LeetCode 2363 - Merge Similar Items

The problem gives us two collections of items, items1 and items2, where every item is represented as a pair: The value acts like a unique identifier for an item, while weight represents that item's associated weight.

leetcodeeasyarrayhash-tablesortingordered-set
LeetCode 2801 - Count Stepping Numbers in Range

The problem asks us to count how many integers in the inclusive range [low, high] are stepping numbers. A stepping number is defined as a number where every pair of adjacent digits differs by exactly 1.

leetcodehardstringdynamic-programming
LeetCode 1979 - Find Greatest Common Divisor of Array

The problem asks us to compute the greatest common divisor (GCD) of two specific values derived from the input array nums: the smallest element in the array and the largest element in the array.

leetcodeeasyarraymathnumber-theory
LeetCode 2619 - Array Prototype Last

The problem asks us to enhance all JavaScript arrays so that they have a convenient method, last(), which returns the last element of the array. If the array is empty, it should return -1.

leetcodeeasy
LeetCode 2757 - Generate Circular Array Values

The problem asks us to create a generator for a circular array, arr, starting from a given index startIndex. A generator is a construct that yields a value each time it is called. The first call to the generator should return the element at startIndex.

leetcodemedium