brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 3496 - Maximize Score After Pair Deletions

We are given an integer array nums. While the array contains more than two elements, we must repeatedly perform one of three operations: 1. Remove the first two elements. 2. Remove the last two elements. 3. Remove the first and last element.

leetcodemediumarraygreedy
LeetCode 3494 - Find the Minimum Amount of Time to Brew Potions

The problem asks us to simulate a sequential brewing process for potions performed by a series of wizards. Each wizard has a skill level that determines the speed at which they brew a potion, while each potion has a mana requirement that affects how long it takes to brew.

leetcodemediumarraysimulationprefix-sum
LeetCode 3491 - Phone Number Prefix

The problem is asking us to determine whether any phone number in a given list is a prefix of another phone number. In simpler terms, if you have a list of strings representing numbers, you need to check that no string starts with another string from the list.

leetcodeeasyarraystringtriesorting
LeetCode 3490 - Count Beautiful Numbers

This problem asks us to count the number of positive integers between l and r (inclusive) that are beautiful. A number is defined as beautiful if the product of its digits is divisible by the sum of its digits.

leetcodeharddynamic-programming
LeetCode 3489 - Zero Array Transformation IV

The problem asks us to determine the minimum number of sequential queries needed to transform an integer array nums into a Zero Array, where every element is zero.

leetcodemediumarraydynamic-programming
LeetCode 3488 - Closest Equal Element Queries

The problem asks us to process a series of queries on a circular array nums. Each query specifies an index, and for that index, we need to find the minimum circular distance to any other index with the same value.

leetcodemediumarrayhash-tablebinary-search
LeetCode 3486 - Longest Special Path II

We are given a rooted tree with n nodes. The tree is rooted at node 0, and every edge has a positive length. Each node also contains a value stored in the array nums. A path is considered special if it satisfies two conditions: 1.

leetcodehardarrayhash-tabletreedepth-first-searchprefix-sum
LeetCode 3480 - Maximize Subarrays After Removing One Conflicting Pair

Here’s a detailed technical solution guide following your requested format for LeetCode 3480 - Maximize Subarrays After Removing One Conflicting Pair. The problem gives you an integer n, which defines a sorted array nums = [1, 2, ..., n].

leetcodehardarraysegment-treeenumerationprefix-sum
LeetCode 3484 - Design Spreadsheet

This problem asks us to design a very small spreadsheet system that supports three operations on cells and one operation for evaluating simple formulas. The spreadsheet always contains exactly 26 columns, labeled 'A' through 'Z', and a configurable number of rows.

leetcodemediumarrayhash-tablestringdesignmatrix
LeetCode 3476 - Maximize Profit from Task Assignment

This problem asks us to assign tasks to workers in order to maximize total profit, under strict skill constraints. Each worker has a skill level, and each task has a required skill and an associated profit.

leetcodemediumarraygreedysortingheap-(priority-queue)
LeetCode 3481 - Apply Substitutions

This problem gives us a collection of replacement rules and a text containing placeholders. Every placeholder has the format %X%, where X is a single uppercase letter corresponding to one of the replacement keys.

leetcodemediumarrayhash-tablestringdepth-first-searchbreadth-first-searchgraph-theorytopological-sort
LeetCode 3474 - Lexicographically Smallest Generated String

We are given two strings: - str1 of length n, containing only 'T' and 'F' - str2 of length m, containing lowercase English letters We must construct a string word of length n + m - 1.

leetcodehardstringgreedystring-matching
LeetCode 3479 - Fruits Into Baskets III

This problem gives us two arrays of equal length: - fruits[i] represents the quantity of the i-th fruit type. - baskets[j] represents the capacity of the j-th basket. We process the fruit types from left to right.

leetcodemediumarraybinary-searchsegment-treeordered-set
LeetCode 3478 - Choose K Elements With Maximum Sum

This problem asks us to compute a "maximum sum" for each index in an array based on a relationship with other elements.

leetcodemediumarraysortingheap-(priority-queue)
LeetCode 3477 - Fruits Into Baskets II

This problem asks us to simulate the placement of fruits into baskets following very specific rules. We are given two arrays of equal length, fruits and baskets.

leetcodeeasyarraybinary-searchsegment-treesimulationordered-set
LeetCode 3475 - DNA Pattern Recognition

This problem provides a database table named Samples that contains DNA sequences and their associated species. Each row represents a single biological sample, identified by a unique sampleid.

leetcodemediumdatabase
LeetCode 3471 - Find the Largest Almost Missing Integer

The problem gives us an integer array nums and an integer k. We consider every contiguous subarray of length k. An integer is called almost missing if it appears in exactly one of those size-k subarrays. Our goal is to find the largest integer that satisfies this property.

leetcodeeasyarrayhash-table
LeetCode 3461 - Check If Digits Are Equal in String After Operations I

This problem asks us to repeatedly transform a string of digits by summing consecutive pairs modulo 10, until only two digits remain, and then check whether those two digits are equal.

leetcodeeasymathstringsimulationcombinatoricsnumber-theory
LeetCode 3472 - Longest Palindromic Subsequence After at Most K Operations

Here’s a complete, detailed technical solution guide for LeetCode 3472 following your formatting rules. The problem asks us to find the length of the longest palindromic subsequence in a string s after performing at most k operations.

leetcodemediumstringdynamic-programming
LeetCode 3470 - Permutations IV

We are given two integers, n and k. We must consider all permutations of the numbers 1 through n that satisfy an alternating parity condition. In a valid permutation, every pair of adjacent elements must have different parity. In other words: - Odd must be followed by even.

leetcodehardarraymathcombinatoricsenumeration
LeetCode 3469 - Find Minimum Cost to Remove Array Elements

The problem is asking for the minimum total cost required to remove all elements from an integer array nums under a very specific set of operations.

leetcodemediumarraydynamic-programming
LeetCode 3467 - Transform Array by Parity

The problem gives us an integer array nums and asks us to transform it using three operations that must be performed in a specific order. First, every even number must be replaced with 0. Second, every odd number must be replaced with 1.

leetcodeeasyarraysortingcounting
LeetCode 3459 - Length of Longest V-Shaped Diagonal Segment

We are given an n x m matrix whose entries are only 0, 1, or 2. A valid V-shaped diagonal segment must satisfy two independent requirements: First, the values along the path must follow a very specific sequence. The first cell must contain 1.

leetcodehardarraydynamic-programmingmemoizationmatrix
LeetCode 3465 - Find Products with Valid Serial Numbers

The problem asks us to query a database table called products to identify rows where the description column contains a valid serial number.

leetcodeeasydatabase
LeetCode 3462 - Maximum Sum With at Most K Elements

We are given a matrix grid, where each row contains a collection of values that can potentially be selected. We are also given an array limits, where limits[i] specifies the maximum number of elements that may be chosen from row i.

leetcodemediumarraygreedysortingheap-(priority-queue)matrix
LeetCode 3463 - Check If Digits Are Equal in String After Operations II

The problem asks us to repeatedly transform a string of digits until only two digits remain, and then check if those two digits are the same. The transformation involves taking each consecutive pair of digits, summing them, and taking the result modulo 10 to form a new digit.

leetcodehardmathstringcombinatoricsnumber-theory
LeetCode 3460 - Longest Common Prefix After at Most One Removal

We are given two lowercase strings, s and t. We may remove at most one character from s. The removal is optional, so we are also allowed to leave s unchanged.

leetcodemediumtwo-pointersstring
LeetCode 3449 - Maximize the Minimum Game Score

You are given an array points, where points[i] is the amount added to gameScore[i] every time you land on index i. The player starts outside the array at position -1.

leetcodehardarraybinary-searchgreedy
LeetCode 3458 - Select K Disjoint Special Substrings

The problem asks us to determine whether we can select k disjoint special substrings from a given string s. A special substring is defined as a substring where every character in it does not appear anywhere else in the string.

leetcodemediumhash-tablestringdynamic-programminggreedysorting
LeetCode 3457 - Eat Pizzas!

The problem presents an array pizzas of size n where each element represents the weight of a pizza. Every day, you must eat exactly 4 pizzas, and the total weight you gain from these 4 pizzas depends on whether the day is odd or even.

leetcodemediumarraygreedysorting
LeetCode 3456 - Find Special Substring of Length K

The problem gives us a string s and an integer k. We need to determine whether there exists a substring of length exactly k that satisfies three conditions. First, every character inside the substring must be identical.

leetcodeeasystring
LeetCode 3454 - Separate Squares II

This problem asks us to find the smallest horizontal line y = H that divides the union area of a collection of axis-aligned squares into two equal halves.

leetcodehardarraybinary-searchsegment-treesweep-line
LeetCode 3450 - Maximum Students on a Single Bench

The problem provides a list of student-seat assignments, where each entry has the form [studentid, benchid]. Each pair indicates that a particular student is sitting on a particular bench.

leetcodeeasyarrayhash-table
LeetCode 3452 - Sum of Good Numbers

This problem gives us an integer array nums and an integer k. For every position i, we need to determine whether nums[i] is a good number.

leetcodeeasyarray
LeetCode 3451 - Find Invalid IP Addresses

This is a SQL database problem where we must identify all invalid IPv4 addresses that appear in the logs table and count how many times each invalid address occurs. The input table contains one row per server access log.

leetcodeharddatabase
LeetCode 3448 - Count Substrings Divisible By Last Digit

We are given a string s consisting only of decimal digits. Every substring of s represents a non-negative integer, and leading zeros are allowed. For each substring, we look at its last digit.

leetcodehardstringdynamic-programming
LeetCode 3446 - Sort Matrix by Diagonals

We are given an n x n square matrix grid. Every cell belongs to exactly one top-left to bottom-right diagonal. Two cells (r1, c1) and (r2, c2) are on the same diagonal if r1 - c1 == r2 - c2.

leetcodemediumarraysortingmatrix
LeetCode 3442 - Maximum Difference Between Even and Odd Frequency I

This problem requires analyzing the frequency of characters in a given string and computing a specific difference. You are given a string s consisting only of lowercase English letters. For each character in the string, you can count how many times it appears.

leetcodeeasyhash-tablestringcounting
LeetCode 3447 - Assign Elements to Groups with Constraints

The problem requires assigning elements from one array, elements, to groups defined by another array, groups, under a divisibility constraint. Specifically, for each group groups[i], we must find the smallest index j in elements such that groups[i] % elements[j] == 0.

leetcodemediumarrayhash-table
LeetCode 3444 - Minimum Increments for Target Multiples in an Array

We are given two arrays: - nums, the array whose elements we are allowed to increase. - target, a small array containing values that must each be represented by at least one multiple somewhere in the final version of nums.

leetcodehardarraymathdynamic-programmingbit-manipulationnumber-theorybitmask
LeetCode 3441 - Minimum Cost Good Caption

We are given a lowercase string caption. We may repeatedly change any character one step forward or backward in the alphabet.

leetcodehardstringdynamic-programming
LeetCode 3440 - Reschedule Meetings for Maximum Free Time II

We are given an event that lasts from time 0 to eventTime. Inside this event there are n non-overlapping meetings, represented by the arrays startTime and endTime.

leetcodemediumarraygreedyenumeration
LeetCode 3439 - Reschedule Meetings for Maximum Free Time I

We are given an event that runs from time 0 to eventTime. Inside this event there are n non-overlapping meetings, already arranged in chronological order.

leetcodemediumarraygreedysliding-window
LeetCode 3437 - Permutations III

We are given a single integer n, and we need to generate all permutations of the numbers from 1 to n. However, not every permutation is valid. A permutation is considered an alternating permutation if every pair of adjacent elements has different parity.

leetcodemediumarraybacktracking
LeetCode 3436 - Find Valid Emails

The problem requires us to identify valid email addresses from a Users table in a database. Each row contains a userid and an email string. The definition of a valid email is very specific: it must contain exactly one @ symbol, end with .

leetcodeeasydatabase
LeetCode 3435 - Frequencies of Shortest Supersequences

The problem asks us to find all shortest common supersequences (SCS) of a given list of two-character strings words. A shortest common supersequence is a string of minimum length that contains each word in words as a subsequence.

leetcodehardarraystringbit-manipulationgraph-theorytopological-sortenumeration
LeetCode 3433 - Count Mentions Per User

This problem asks us to simulate a sequence of user activity events and count how many times each user is mentioned across all message events.

leetcodemediumarraymathsortingsimulation
LeetCode 3428 - Maximum and Minimum Sums of at Most Size K Subsequences

We are given an array nums and an integer k. For every subsequence whose size is at most k, we look at two values: - The minimum element in that subsequence. - The maximum element in that subsequence.

leetcodemediumarraymathdynamic-programmingsortingcombinatorics
LeetCode 3429 - Paint House IV

This problem is asking us to paint n houses arranged in a line with three available colors for each house, minimizing the total painting cost while satisfying two constraints.

leetcodemediumarraydynamic-programming
LeetCode 3427 - Sum of Variable Length Subarrays

The problem provides an integer array nums of length n. For each index i, we are asked to consider a subarray that ends at i but starts at start = max(0, i - nums[i]).

leetcodeeasyarrayprefix-sum
LeetCode 3425 - Longest Special Path

This problem provides an undirected tree rooted at node 0 with n nodes and weighted edges, where each node has a value defined in the array nums. A special path is a downward path (from ancestor to descendant) such that all node values along the path are unique.

leetcodehardarrayhash-tabletreedepth-first-searchprefix-sum
LeetCode 3424 - Minimum Cost to Make Arrays Identical

The problem asks us to transform one integer array arr into another integer array brr with the minimum cost using two types of operations. The first operation allows splitting arr into contiguous subarrays and rearranging them at a fixed cost k per operation.

leetcodemediumarraygreedysorting
LeetCode 3423 - Maximum Difference Between Adjacent Elements in a Circular Array

This problem gives us an integer array nums and asks us to find the largest absolute difference between any two adjacent elements. The important detail is that the array is circular.

leetcodeeasyarray
LeetCode 3422 - Minimum Operations to Make Subarray Elements Equal

We are given an array nums and an integer k. In a single operation, we may increase or decrease any element by exactly 1. Our goal is not to make the entire array equal. Instead, we only need at least one contiguous subarray of length k to consist entirely of the same value.

leetcodemediumarrayhash-tablemathsliding-windowheap-(priority-queue)
LeetCode 3420 - Count Non-Decreasing Subarrays After K Operations

You are given an array nums and a budget of at most k increment operations. For any chosen subarray, you may repeatedly pick an element inside that subarray and increase it by 1.

leetcodehardarraystacksegment-treequeuesliding-windowmonotonic-stackmonotonic-queue
LeetCode 3418 - Maximum Amount of Money Robot Can Earn

We are given an m x n grid where each cell contains either a positive value, zero, or a negative value. The robot starts at the top-left cell (0, 0) and must reach the bottom-right cell (m - 1, n - 1).

leetcodemediumarraydynamic-programmingmatrix
LeetCode 3417 - Zigzag Grid Traversal With Skip

This problem asks us to traverse a two-dimensional grid in a zigzag order while visiting only every other cell in the traversal sequence. The zigzag traversal follows a very specific pattern: - Start at the top-left corner (0, 0). - Traverse the first row from left to right.

leetcodeeasyarraymatrixsimulation
LeetCode 3416 - Subsequences with a Unique Middle Mode II

We are given an array nums, and we must count how many subsequences of length exactly 5 have a very specific property. For any chosen subsequence the middle element is c, because it is the third element of a length-5 sequence. The subsequence is valid if: 1.

leetcodehardarrayhash-tablemathcombinatorics
LeetCode 3413 - Maximum Coins From K Consecutive Bags

We are given several non-overlapping segments on a number line. Each segment [l, r, c] means that every bag at positions l, l+1, ..., r contains exactly c coins. All positions not covered by any segment contain 0 coins.

leetcodemediumarraybinary-searchgreedysliding-windowsortingprefix-sum
LeetCode 3411 - Maximum Subarray With Equal Products

We are given an array nums consisting of positive integers. For any array arr, define: - prod(arr) as the product of all elements. - gcd(arr) as the greatest common divisor of all elements. - lcm(arr) as the least common multiple of all elements.

leetcodeeasyarraymathsliding-windowenumerationnumber-theory
LeetCode 3409 - Longest Subsequence With Decreasing Adjacent Difference

We are given an array nums, and we want to choose a subsequence from it. A subsequence preserves the original order of elements but may skip arbitrary positions.

leetcodemediumarraydynamic-programming
LeetCode 3408 - Design Task Manager

This problem asks us to design a data structure that maintains a collection of tasks belonging to different users.

leetcodemediumhash-tabledesignheap-(priority-queue)ordered-set
LeetCode 3407 - Substring Matching Pattern

The problem gives us two strings: - s, the source string. - p, a pattern string containing exactly one ''. The special character '' can represent any sequence of characters, including an empty sequence.

leetcodeeasystringstring-matching
LeetCode 3403 - Find the Lexicographically Largest String From the Box I

We are given a string word of length n and an integer numFriends. In each round, the string is split into exactly numFriends non-empty contiguous pieces. Every distinct way to place the numFriends - 1 cuts is considered a different round.

leetcodemediumtwo-pointersstringenumeration
brute forcemath
LeetCode 3376 - Minimum Time to Break Locks I

The problem describes a sequence of locks that must all be broken. Each lock requires a certain amount of energy, given by strength[i]. Bob's sword starts with: - Energy = 0 - Growth factor x = 1 Every minute, the sword gains x energy.

leetcodemediumarraydynamic-programmingbacktrackingbit-manipulationbreadth-first-searchbitmask
LeetCode 3183 - The Number of Ways to Make the Sum

The problem asks us to determine the number of distinct ways to sum up to an integer n using a limited set of coins. Specifically, we have coins of value 1, 2, and 6 available in infinite quantities, and coins of value 4 with a strict limit of two.

leetcodemediumarraydynamic-programming
LeetCode 1847 - Closest Room

We are given a list of hotel rooms, where each room has: - A unique room ID - A room size We are also given several queries.

leetcodehardarraybinary-searchsortingordered-set
LeetCode 3399 - Smallest Substring With Identical Characters II

We are given a binary string s consisting only of '0' and '1', along with an integer numOps. In one operation, we may choose any index and flip the bit at that position. A '0' becomes '1', and a '1' becomes '0'.

leetcodehardstringbinary-search
LeetCode 3390 - Longest Team Pass Streak

This problem asks us to analyze a football match pass sequence and determine, for every team, the longest uninterrupted sequence of successful passes between players on the same team. We are given two tables: The Teams table maps each playerid to a teamname.

leetcodeharddatabase
LeetCode 3375 - Minimum Operations to Make Array Values Equal to K

The problem gives us an integer array nums and a target value k. Our goal is to transform the entire array so that every element becomes exactly equal to k. However, we cannot arbitrarily change values. Each operation follows a very specific rule.

leetcodeeasyarrayhash-table
LeetCode 3372 - Maximize the Number of Target Nodes After Connecting Trees I

We are given two separate undirected trees. The first tree contains n nodes labeled from 0 to n - 1, and the second tree contains m nodes labeled from 0 to m - 1. A node u is considered a target node for another node v if the shortest path distance between them is at most k.

leetcodemediumtreedepth-first-searchbreadth-first-search
LeetCode 3360 - Stone Removal Game

In this game, Alice and Bob take turns removing stones from a pile. The rules are very strict because the number of stones removed on each turn is predetermined. Alice always goes first and must remove exactly 10 stones on her first move.

leetcodeeasymathsimulation
LeetCode 3335 - Total Characters in String After Transformations I

The problem gives us a string s and an integer t. We repeatedly apply a transformation exactly t times. During one transformation: - Every character from 'a' to 'y' becomes the next character in the alphabet. - The character 'z' becomes the string "ab".

leetcodemediumhash-tablemathstringdynamic-programmingcounting
LeetCode 3333 - Find the Original Typed String II

The problem asks us to determine the number of possible original strings that Alice could have intended to type, given a string word that represents the final output and an integer k representing the minimum length of the original string.

leetcodehardstringdynamic-programmingprefix-sum
LeetCode 3270 - Find the Key of the Numbers

The problem gives us three positive integers, num1, num2, and num3. We must construct a new number called the key using the digits of these three numbers. The important detail is that every number must first be treated as a four digit number.

leetcodeeasymath
LeetCode 3260 - Find the Largest Palindrome Divisible by K

The problem asks us to construct the largest possible palindrome with exactly n digits such that the resulting number is divisible by k. A palindrome is a number that reads the same forward and backward. For example, 595, 1221, and 8 are palindromes.

leetcodehardmathstringdynamic-programminggreedynumber-theory
LeetCode 3224 - Minimum Array Changes to Make Differences Equal

The problem gives us an integer array nums of even length n and an integer k. We are allowed to change any element in nums to any integer in the range [0, k].

leetcodemediumarrayhash-tableprefix-sum
LeetCode 3206 - Alternating Groups I

The problem gives us a circular array called colors, where each element represents the color of a tile: - 0 means red - 1 means blue Because the tiles form a circle, the first and last tiles are considered adjacent.

leetcodeeasyarraysliding-window
LeetCode 3188 - Find Top Scoring Students II

This problem asks us to identify students who satisfy a combination of academic requirements based on their major, completed courses, grades, and overall GPA. We are given three tables: - The students table stores each student's identity and declared major.

leetcodeharddatabase
LeetCode 3176 - Find the Maximum Length of a Good Subsequence I

We are given an integer array nums and a non-negative integer k. We need to find the maximum possible length of a subsequence such that the number of adjacent unequal pairs is at most k.

leetcodemediumarrayhash-tabledynamic-programming
LeetCode 3151 - Special Array I

The problem asks us to determine whether a given integer array is "special". An array is considered special if every pair of adjacent elements has different parity. Parity refers to whether a number is even or odd.

leetcodeeasyarray
LeetCode 3119 - Maximum Number of Potholes That Can Be Fixed

We are given a road represented as a string containing only two characters: - 'x' represents a pothole. - '.' represents a smooth section of road. We are also given a repair budget. A repair operation can only be applied to a contiguous group of potholes.

leetcodemediumstringgreedysorting
LeetCode 3135 - Equalize Strings by Adding or Removing Characters at Ends

The problem gives us two strings, initial and target. We want to transform initial into target using the minimum number of operations.

leetcodemediumstringbinary-searchdynamic-programmingsliding-windowhash-function
LeetCode 3108 - Minimum Cost Walk in Weighted Graph

This problem gives us an undirected weighted graph with n vertices and up to 10^5 edges. Each edge connects two vertices and has an integer weight. For every query [s, t], we must determine the minimum possible cost of any walk from node s to node t.

leetcodehardarraybit-manipulationunion-findgraph-theory
LeetCode 3074 - Apple Redistribution into Boxes

The problem asks us to redistribute a collection of apple packs into boxes while using the minimum number of boxes. Each pack apple[i] contains a certain number of apples, and each box capacity[j] can hold up to a certain number of apples.

leetcodeeasyarraygreedysorting
LeetCode 2976 - Minimum Cost to Convert String I

This problem asks us to transform one string into another while minimizing the total conversion cost. We are given two strings, source and target, both with the same length. Each position in source must eventually become the corresponding character in target.

leetcodemediumarraystringgraph-theoryshortest-path
LeetCode 2999 - Count the Number of Powerful Integers

The problem asks us to count all integers within a given range [start, finish] that satisfy two conditions. First, the integer must end with a specific string s, meaning s is a suffix of the number. Second, each digit in the integer cannot exceed a given limit.

leetcodehardmathstringdynamic-programming
LeetCode 2740 - Find the Value of the Partition

We are given an array nums containing positive integers. Our task is to divide all elements into two non-empty groups, nums1 and nums2. Every element must belong to exactly one of the two groups, and neither group may be empty.

leetcodemediumarraysorting
LeetCode 2527 - Find Xor-Beauty of Array

The problem defines a special value called the "effective value" for every possible triplet of indices (i, j, k) in the array: where: - | is the bitwise OR operator - & is the bitwise AND operator The xor-beauty of the array is the XOR of the effective values for all possible…

leetcodemediumarraymathbit-manipulation
LeetCode 2387 - Median of a Row Wise Sorted Matrix

We are given an m × n matrix grid where every row is already sorted in non-decreasing order. The total number of elements in the matrix is guaranteed to be odd because both m and n are odd. The task is to find the median of all values contained in the matrix.

leetcodemediumarraybinary-searchmatrix
LeetCode 1992 - Find All Groups of Farmland

In this problem, we are given a binary matrix called land. Each cell contains either: - 0, representing forest land - 1, representing farmland The farmland cells are organized into rectangular groups. Every group is guaranteed to form a perfect rectangle made entirely of 1s.

leetcodemediumarraydepth-first-searchbreadth-first-searchmatrix
LeetCode 1960 - Maximum Product of the Length of Two Palindromic Substrings

The problem asks us to find two non-overlapping odd-length palindromic substrings whose length product is as large as possible. We are given a string s of length up to 10^5.

leetcodehardtwo-pointersstringrolling-hashhash-function
LeetCode 1963 - Minimum Number of Swaps to Make the String Balanced

The problem asks us to transform a given string of brackets into a balanced string with the minimum number of swaps. The input string s consists of n characters, where n is even, and there are exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.

leetcodemediumtwo-pointersstringstackgreedy
LeetCode 1913 - Maximum Product Difference Between Two Pairs

This problem asks us to find the maximum product difference between two pairs of numbers from a given array. Specifically, given an array nums, we need to select four distinct indices w, x, y, z to form two pairs (nums[w], nums[x]) and (nums[y], nums[z]).

leetcodeeasyarraysorting
LeetCode 1782 - Count Pairs Of Nodes

We are given an undirected graph with n nodes and a list of edges. Multiple edges between the same pair of nodes are allowed. For any pair of nodes (a, b), define incident(a, b) as the number of edges connected to either node a or node b.

leetcodehardarrayhash-tabletwo-pointersbinary-searchgraph-theorysortingcounting
LeetCode 1880 - Check if Word Equals Summation of Two Words

The problem asks us to determine if the sum of the numerical values of two words equals the numerical value of a third word. Each word consists of lowercase letters from 'a' to 'j'.

leetcodeeasystring
LeetCode 1867 - Orders With Maximum Quantity Above Average

The problem asks us to identify "imbalanced orders" from an OrdersDetails table. Each row represents a product within an order, containing the orderid, productid, and quantity ordered. An order can have multiple products, meaning multiple rows can share the same orderid.

leetcodemediumdatabase
LeetCode 1851 - Minimum Interval to Include Each Query

The problem gives us a collection of inclusive integer intervals and a list of query values. For every query, we must determine the size of the smallest interval that contains that query value.

leetcodehardarraybinary-searchsweep-linesortingheap-(priority-queue)
LeetCode 1844 - Replace All Digits with Characters

In this problem, we are given a string s where characters at even indices are always lowercase English letters, and characters at odd indices are always digits. The goal is to replace every digit with a new character computed from the character immediately before it.

leetcodeeasystring