brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 2228 - Users With Two Purchases Within Seven Days

The problem requires identifying users who made at least two purchases within a 7-day window. We are given a Purchases table with purchaseid, userid, and purchasedate. Each row represents a single purchase made by a user.

leetcodemediumdatabase
CF 173A - Rock-Paper-Scissors

In this problem, two players, Nikephoros and Polycarpus, play multiple rounds of rock-paper-scissors. Each player has a fixed sequence of moves that they cycle through as the rounds progress.

codeforcescompetitive-programmingimplementationmath
CF 251A - Points on Line

We are given a set of points positioned along a one-dimensional line. Petya wants to count how many triplets of points can be chosen such that the distance between the leftmost and rightmost points in the triplet does not exceed a given value d.

codeforcescompetitive-programmingbinary-searchcombinatoricstwo-pointers
LeetCode 2805 - Custom Interval

This problem asks us to implement a custom version of setInterval, but with a key difference. Instead of using a fixed delay between executions, the delay grows linearly according to the formula: where count starts at 0 and increases after every execution.

leetcodemedium
LeetCode 2689 - Extract Kth Character From The Rope Tree

Edit This problem asks us to retrieve the k-th character from a string represented by a special binary tree called a rope tree. Instead of storing one large string directly, the string is distributed across the tree structure.

leetcodeeasytreedepth-first-searchbinary-tree
LeetCode 3204 - Bitwise User Permissions Analysis

The problem is asking us to analyze a table of user permissions where each user's permissions are encoded as an integer. Each bit in this integer represents a distinct access level or feature.

leetcodemediumdatabase
LeetCode 2261 - K Divisible Elements Subarrays

This problem requires counting the number of distinct subarrays of a given integer array nums that satisfy a specific constraint: each subarray can contain at most k elements divisible by p.

leetcodemediumarrayhash-tabletrierolling-hashhash-functionenumeration
CF 246D - Colorful Graph

We are given an undirected graph where each vertex has a color, represented by an integer. The goal is to determine which color has the most diverse set of neighboring colors.

codeforcescompetitive-programmingbrute-forcedfs-and-similargraphs
LeetCode 2119 - A Number After a Double Reversal

The problem asks us to determine whether a number remains unchanged after performing two digit reversals. A digit reversal means reading the digits of a number from right to left.

leetcodeeasymath
CF 439A - Devu, the Singer and Churu, the Joker

The problem asks us to schedule an event where Devu, a singer, performs n songs of varying lengths, and Churu, a comedian, tells jokes of fixed 5-minute duration.

codeforcescompetitive-programminggreedyimplementation
LeetCode 3201 - Find the Maximum Length of Valid Subsequence I

The problem asks us to find the longest subsequence in an integer array nums where each adjacent pair of elements in the subsequence has the same parity sum, modulo 2.

leetcodemediumarraydynamic-programming
LeetCode 2721 - Execute Asynchronous Functions in Parallel

This problem asks us to implement a custom version of Promise.all, but without using the built in Promise.all API. We are given an array called functions, where every element is an asynchronous function. Each function takes no arguments and returns a promise when executed.

leetcodemedium
CF 241F - Race

The city is represented by a grid. Every cell is either a building, a street tile with a traversal cost from 1 to 9, or a junction labeled by a lowercase letter. Movement rules are unusual.

codeforcescompetitive-programmingbrute-forceimplementation
CF 162D - Remove digits

We are given a single string containing printable ASCII characters. Some of those characters may be digits from '0' to '9'. The task is to remove every digit and print the remaining characters in their original order.

codeforcescompetitive-programming*special
LeetCode 1761 - Minimum Degree of a Connected Trio in a Graph

This problem gives us an undirected graph with n nodes and a list of edges. A connected trio is a group of exactly three distinct nodes where every pair of nodes has an edge between them. In graph theory terms, this is simply a triangle.

leetcodehardgraph-theoryenumeration
LeetCode 2412 - Minimum Money Required Before Transactions

The problem asks us to determine the minimum initial money required to complete all transactions in any order. Each transaction is defined by [costi, cashbacki], meaning that performing the transaction requires at least costi money, and after completing it, we receive…

leetcodehardarraygreedysorting
LeetCode 2134 - Minimum Swaps to Group All 1's Together II

The problem is asking us to find the minimum number of swaps required to group all 1s in a binary circular array together at any contiguous segment. The array is circular, which means the end of the array wraps around to the beginning.

leetcodemediumarraysliding-window
LeetCode 3353 - Minimum Total Operations

The problem is asking us to determine the minimum number of operations required to make all elements of an array equal, given a very specific operation. The operation allows choosing a prefix of the array, selecting any integer k, and adding k to every element in that prefix.

leetcodeeasyarray
LeetCode 2396 - Strictly Palindromic Number

The problem asks whether a given integer n is strictly palindromic. A number is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), its representation in base b reads the same forwards and backwards.

leetcodemediummathtwo-pointersbrainteaser
CF 255C - Almost Arithmetical Progression

We are given a sequence of integers and asked to find the longest subsequence that forms an almost arithmetical progression.

codeforcescompetitive-programmingbrute-forcedp
LeetCode 2317 - Maximum XOR After Operations

The problem gives us an integer array nums, and we may perform a special operation any number of times. In one operation, we choose an index i and any non-negative integer x, then replace: Our goal is to maximize the bitwise XOR of all elements in the array after performing as…

leetcodemediumarraymathbit-manipulation
CF 215E - Periodical Numbers

We are asked to count numbers in a given range [l, r] whose binary representations are periodic. A number is periodic if its binary string has a repeating pattern of length k that divides the total length n of the string, meaning every segment of length k repeats exactly…

codeforcescompetitive-programmingcombinatoricsdpnumber-theory
LeetCode 3207 - Maximum Points After Enemy Battles

The problem gives us a list of enemies, where each enemy has an associated energy value. We also start with some initial amount of energy called currentEnergy. We begin with zero points, and every enemy starts as unmarked.

leetcodemediumarraygreedy
LeetCode 2588 - Count the Number of Beautiful Subarrays

The problem gives us an array nums, and we are allowed to repeatedly perform a special operation on pairs of elements.

leetcodemediumarrayhash-tablebit-manipulationprefix-sum
LeetCode 2361 - Minimum Costs Using the Train Line

This problem models a scenario where you are traversing a train line with two parallel routes: a regular route and an express route. Each route has a series of consecutive stops, and the cost to move from one stop to the next is provided in the arrays regular and express.

leetcodehardarraydynamic-programming
LeetCode 2788 - Split Strings by Separator

This problem asks us to process an array of strings and split each string using a given separator character. After performing all splits, we must collect every resulting substring into a single output array while preserving the original order.

leetcodeeasyarraystring
CF 158B - Taxi

We have a collection of schoolchildren organized into groups, and each group wants to travel together in a taxi. Each group has between one and four children, and each taxi can carry at most four children.

codeforcescompetitive-programming*specialgreedyimplementation
CF 414D - Mashmokh and Water Tanks

We are given a rooted tree where each vertex represents a water tank. Initially all tanks are empty, but we are allowed to place up to $k$ liters of water, each liter placed into a distinct non-root node.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedytreestwo-pointers
LeetCode 2101 - Detonate the Maximum Bombs

In this problem, each bomb is represented by three integers: its x-coordinate, y-coordinate, and explosion radius. If a bomb explodes, every other bomb whose center lies within or on the boundary of that radius will also explode.

leetcodemediumarraymathdepth-first-searchbreadth-first-searchgraph-theorygeometry
CF 250B - Restoring IPv6

An IPv6 address in its full form is a fixed structure made of eight blocks. Each block represents 16 bits and is written as exactly four hexadecimal characters, including leading zeros when necessary.

codeforcescompetitive-programmingimplementationstrings
CF 306A - Candies

Polycarpus has a certain number of candies and a number of friends. He wants to distribute all the candies among his friends in such a way that every friend gets a positive number of candies, and the difference between the friend who receives the most candies and the friend…

codeforcescompetitive-programmingimplementation
LeetCode 2633 - Convert Object to JSON String

The problem asks us to manually implement the behavior of JavaScript's JSON.stringify for valid JSON values, without using the built in function itself.

leetcodemedium
LeetCode 2381 - Shifting Letters II

This problem gives us a lowercase English string s and a list of shift operations. Each operation is represented as: The operation affects every character from index start to index end, inclusive.

leetcodemediumarraystringprefix-sum
CF 354C - Vasya and Beautiful Arrays

We start with an array of positive integers. For every element, we are allowed to decrease it by at most k, and the value must stay positive.

codeforcescompetitive-programmingbrute-forcedpnumber-theory
LeetCode 3024 - Type of Triangle

The problem gives an integer array nums of length 3, where each value represents the length of a side of a possible triangle. Our task is to determine what kind of triangle these three sides can form.

leetcodeeasyarraymathsorting
LeetCode 2764 - Is Array a Preorder of Some ‌Binary Tree

The problem asks us to determine whether a given list of nodes represents the preorder traversal of a binary tree. Each node is represented as a pair [id, parentId], where id is the unique identifier of the node, and parentId identifies its parent in the tree.

leetcodemediumstacktreedepth-first-searchbinary-tree
CF 250E - Mad Joe

Joe is starting on the top floor of a multi-story building represented as a grid of cells. Each floor is a row of m cells, and each cell can either be empty, contain breakable bricks, or be an unbreakable concrete wall.

codeforcescompetitive-programmingbrute-force
LeetCode 2569 - Handling Sum Queries After Update

This problem gives us two arrays, nums1 and nums2, both of the same length n, along with a list of queries. Each query modifies one of the arrays or asks for information about them.

leetcodehardarraysegment-tree
LeetCode 2865 - Beautiful Towers I

The problem asks us to transform an array of tower heights into a mountain-shaped arrangement while removing as few bricks as necessary.

leetcodemediumarraystackmonotonic-stack
LeetCode 2710 - Remove Trailing Zeros From a String

The problem asks us to remove all trailing zeros from a string representing a positive integer. The input num is a string consisting only of digits with no leading zeros, and the length of the string is between 1 and 1000.

leetcodeeasystring
LeetCode 2213 - Longest Substring of One Repeating Character

The problem gives us an initial string s and a sequence of update operations. Each update changes exactly one character in the string. After every update, we must determine the length of the longest contiguous substring that contains only one repeating character.

leetcodehardarraystringsegment-treeordered-set
LeetCode 2606 - Find the Substring With Maximum Cost

The problem asks us to find the substring of a given string s that maximizes a custom cost function. Each character in the string has a value: if it exists in the string chars, its value is taken from the corresponding index in the array vals; if it does not exist in chars…

leetcodemediumarrayhash-tablestringdynamic-programming
LeetCode 2522 - Partition String Into Substrings With Values at Most K

The problem gives us a numeric string s, where every character is a digit between '1' and '9', and an integer k. We must split the string into contiguous substrings such that every substring, when interpreted as an integer, has a value less than or equal to k.

leetcodemediumstringdynamic-programminggreedy
LeetCode 2624 - Snail Traversal

The problem asks us to take a 1D array of integers and convert it into a 2D matrix of specified dimensions, rowsCount and colsCount, following a snail traversal order by columns.

leetcodemedium
LeetCode 2995 - Viewers Turned Streamers

We are given a database table called Sessions, where each row represents one user session on a platform. Every session belongs to a specific userid, has a start and end timestamp, a unique sessionid, and a sessiontype that can be either "Viewer" or "Streamer".

leetcodeharddatabase
CF 164C - Machine Programming

We have several jobs, each with a start time, a duration, and a profit. A machine that starts a job stays occupied for the entire interval from s through s + t - 1. At most k jobs may run simultaneously because we only own k machines. The goal is not to schedule all jobs.

codeforcescompetitive-programmingflowsgraphs
LeetCode 2108 - Find First Palindromic String in the Array

The problem asks us to examine an array of strings, words, and identify the first string that is a palindrome. A palindrome is a string that reads the same forward and backward.

leetcodeeasyarraytwo-pointersstring
CF 427B - Prison Transfer

We have a line of prisoners, and each prisoner has a crime severity value. We must choose exactly c consecutive prisoners for transfer. Every prisoner inside the chosen segment must have severity at most t.

codeforcescompetitive-programmingdata-structuresimplementation
LeetCode 3331 - Find Subtree Sizes After Changes

We are given a rooted tree with n nodes numbered from 0 to n - 1. The tree structure is represented by the parent array, where parent[i] is the parent of node i. Since node 0 is the root, its parent is -1.

leetcodemediumarrayhash-tablestringtreedepth-first-search
LeetCode 2163 - Minimum Difference in Sums After Removal of Elements

The array contains exactly 3 n elements. We must remove exactly n elements, leaving 2 n elements behind. The remaining elements keep their original relative order because we are removing a subsequence, not rearranging the array.

leetcodehardarraydynamic-programmingheap-(priority-queue)
LeetCode 2687 - Bikes Last Time Used

The problem requires us to identify the last time each bike was used based on a table of rides. Each row of the table corresponds to a unique ride and contains the rideid, bikenumber, starttime, and endtime.

leetcodeeasydatabase
LeetCode 2998 - Minimum Number of Operations to Make X and Y Equal

The problem asks us to transform an integer x into another integer y using the minimum number of operations. At every step, we are allowed to perform exactly one of four actions: 1. Divide x by 11 if it is divisible by 11. 2. Divide x by 5 if it is divisible by 5. 3.

leetcodemediumdynamic-programmingbreadth-first-searchmemoization
LeetCode 3209 - Number of Subarrays With AND Value of K

The problem asks us to count how many contiguous subarrays of nums have a bitwise AND equal to k. A subarray is any contiguous segment of the array. For every possible subarray, we compute the bitwise AND of all elements inside it.

leetcodehardarraybinary-searchbit-manipulationsegment-tree
LeetCode 2627 - Debounce

This problem asks us to implement a utility function called debounce. The function receives two inputs: - A function fn - A delay value t in milliseconds The goal is to return a new function, called the debounced version of fn.

leetcodemedium
LeetCode 2884 - Modify Columns

The problem provides a Pandas DataFrame named employees with two columns: | Column | Type | | --- | --- | | name | object | | salary | int | Each row represents one employee and their current salary.

leetcodeeasy
LeetCode 3289 - The Two Sneaky Numbers of Digitville

The problem is asking us to identify two numbers that appear twice in an otherwise consecutive list of integers ranging from 0 to n - 1.

leetcodeeasyarrayhash-tablemath
CF 261D - Maxim and Increasing Subsequence

Codeforces 261D: Maxim and Increasing Subsequence

codeforcescompetitive-programmingdp
CF 421A - Pasha and Hamsters

We are given a line of apples numbered from 1 to n. Each apple can be given to exactly one of two hamsters, Arthur or Alexander. The only restriction is that Arthur must receive only apples he likes, and Alexander must receive only apples he likes.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
LeetCode 2723 - Add Two Promises

This problem asks us to work with JavaScript promises and asynchronous execution. We are given two promises, promise1 and promise2, and each promise is guaranteed to eventually resolve to a numeric value.

leetcodeeasy
LeetCode 3200 - Maximum Height of a Triangle

The problem gives us two integers, red and blue, representing the number of red and blue balls available. We want to build a triangle where: - Row 1 contains exactly 1 ball - Row 2 contains exactly 2 balls - Row 3 contains exactly 3 balls - And so on There are two additional…

leetcodeeasyarrayenumeration
LeetCode 2183 - Count Array Pairs Divisible by K

The problem gives us an integer array nums and an integer k. We must count how many index pairs (i, j) satisfy two conditions: 1. i < j 2.

leetcodehardarrayhash-tablemathcountingnumber-theory
LeetCode 2230 - The Users That Are Eligible for Discount

This problem asks us to identify all users who qualify for a discount based on their purchase history stored in the Purchases table.

leetcodeeasydatabase
LeetCode 3276 - Select Cells in Grid With Maximum Score

The problem requires us to select cells from a 2D matrix grid such that no two selected cells are in the same row, and all selected values are unique. Our goal is to maximize the sum of these selected values.

leetcodehardarraydynamic-programmingbit-manipulationmatrixbitmask
LeetCode 3357 - Minimize the Maximum Adjacent Element Difference

The problem gives us an integer array nums, where some positions contain -1. These -1 values represent missing elements that must be replaced. The key restriction is that we are allowed to choose exactly two positive integers, x and y, one time globally for the entire array.

leetcodehardarraybinary-searchgreedy
CF 164B - Ancient Berland Hieroglyphs

The problem involves two circular sequences of unique hieroglyphs. We are asked to "cut" these circles at some point to turn them into linear arrays, then find the longest contiguous segment from the first array that appears as a subsequence in the second array.

codeforcescompetitive-programmingtwo-pointers
LeetCode 2817 - Minimum Absolute Difference Between Elements With Constraint

We are given an integer array nums and an integer x. We need to find two elements whose indices are separated by at least x, and among all such valid pairs, return the minimum possible absolute difference between their values.

leetcodemediumarraybinary-searchordered-set
LeetCode 2059 - Minimum Operations to Convert Number

This problem asks us to transform a starting integer into a target integer using the minimum number of operations.

leetcodemediumarraybreadth-first-search
CF 251D - Two Sets

We are given a sequence of non-negative integers and must split it into two groups. One group remains with Petya and the other is given to Masha. For each group we compute the XOR of all numbers assigned to it, and we call these values x1 and x2.

codeforcescompetitive-programmingbitmasksmath
LeetCode 2046 - Sort Linked List Already Sorted Using Absolute Values

The problem provides a singly linked list where the nodes are sorted in non-decreasing order by their absolute values, rather than their actual values. The task is to rearrange this list so that the nodes are sorted in non-decreasing order according to their actual values.

leetcodemediumlinked-listtwo-pointerssorting
LeetCode 2540 - Minimum Common Value

The problem gives us two integer arrays, nums1 and nums2, and both arrays are already sorted in non-decreasing order. Our task is to find the smallest integer that appears in both arrays. If there is no value shared between the two arrays, we must return -1.

leetcodeeasyarrayhash-tabletwo-pointersbinary-search
LeetCode 3248 - Snake in Matrix

The problem describes a snake moving inside an n x n grid. Every cell in the grid is assigned a numeric position using the formula: This means the grid is numbered row by row, starting from the top-left corner.

leetcodeeasyarraystringsimulation
LeetCode 2251 - Number of Flowers in Full Bloom

The problem asks us to determine, for a list of people arriving at certain times, how many flowers are in full bloom at the time of their arrival. Each flower has a start and end time representing the period it is in full bloom, inclusive of both endpoints.

leetcodehardarrayhash-tablebinary-searchsortingprefix-sumordered-set
LeetCode 2574 - Left and Right Sum Differences

The problem asks us to compute the absolute difference between the sum of elements to the left and the sum of elements to the right for each element in a given array nums. In other words, for every index i, we want to know how different the sums on either side of that index are.

leetcodeeasyarrayprefix-sum
LeetCode 1973 - Count Nodes Equal to Sum of Descendants

This problem asks us to analyze a binary tree and count how many nodes satisfy a specific property: the value of the node equals the sum of all its descendants. A descendant of a node is any node that lies in the subtree rooted at that node excluding the node itself.

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 3378 - Count Connected Components in LCM Graph

We are given an array nums, where each element represents the value assigned to a node in a graph. The graph contains exactly n nodes, one node for each array element.

leetcodehardarrayhash-tablemathunion-findnumber-theory
CF 174C - Range Increments

We start with an array of length n filled with zeros. One operation chooses a segment [l, r] and adds 1 to every element inside that segment. The final array is given.

codeforcescompetitive-programmingdata-structuresgreedy
CF 161B - Discounts

We have a collection of items sold in a supermarket. Every item has a price and a type. Type 1 means the item is a stool, type 2 means it is a pencil. Polycarpus owns exactly k shopping carts, and every cart must contain at least one item.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortings
LeetCode 2223 - Sum of Scores of Built Strings

The problem gives us a final string s and describes a process where the string is built by repeatedly prepending characters to the front. This means that every intermediate string si is actually a suffix of the final string s.

leetcodehardstringbinary-searchrolling-hashsuffix-arraystring-matchinghash-function
CF 254B - Jury Size

Each Olympiad happens on a fixed calendar date in 2013. Before that date, a group of jury members must work continuously for several days. If an Olympiad needs p people and t preparation days, then exactly p people are busy on each of the t days immediately before the Olympiad.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 2743 - Count Substrings Without Repeating Character

The problem asks us to count how many substrings of a given string contain only unique characters. A substring is considered special if no character appears more than once inside that substring. We are given a string s containing only lowercase English letters.

leetcodemediumhash-tablestringsliding-window
LeetCode 2762 - Continuous Subarrays

That is a long, structured technical guide. To make sure I target the correct problem and avoid wasting your time, can you confirm the exact LeetCode problem title for 2762?

leetcodemediumarrayqueuesliding-windowheap-(priority-queue)ordered-setmonotonic-queue
CF 238A - Not Wool Sequences

We work with arrays of length n, where every element is an integer from 0 to 2^m - 1. A sequence is called "wool" if there exists some contiguous subarray whose xor is 0. We are asked to count how many sequences are not wool, meaning every contiguous subarray has non-zero xor.

codeforcescompetitive-programmingconstructive-algorithmsmath
LeetCode 2277 - Closest Node to Path in Tree

The problem is asking us to process queries on a tree structure. Each query gives a path between two nodes starti and endi and a third node nodei.

leetcodehardarraytreedepth-first-searchbreadth-first-search
LeetCode 2238 - Number of Times a Driver Was a Passenger

The problem provides a table Rides that records rides between drivers and passengers. Each row has a unique rideid, a driverid, and a passengerid. The task is to determine, for each driver, how many times that driver has appeared as a passenger in the table.

leetcodemediumdatabase
CF 431B - Shower Line

We have exactly five students standing in a line for a shower. While one student is showering, the remaining students wait in line and talk in adjacent pairs. The first and second students talk, the third and fourth students talk, and so on.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 2746 - Decremental String Concatenation

The problem gives us an array of strings words. We start with words[0] and then process the remaining strings one by one. For each new word words[i], we have exactly two choices: 1. Append it to the right side of the current string. 2.

leetcodemediumarraystringdynamic-programming
LeetCode 2639 - Find the Width of Columns of a Grid

The problem gives us a two dimensional integer matrix called grid with m rows and n columns. Our task is to compute the width of every column independently. The width of a column is defined as the maximum string length among all integers appearing in that column.

leetcodeeasyarraymatrix
LeetCode 1927 - Sum Game

The problem describes a two player game played on a numeric string of even length. The string contains digits and possibly some '?' characters. Alice and Bob alternate turns replacing one '?' with a digit from '0' to '9'. Alice moves first. At the end of the game, every '?

leetcodemediummathstringgreedygame-theory
CF 145A - Lucky Conversion

We are given two strings of equal length, both consisting only of the characters 4 and 7. The goal is to transform the first string into the second using the fewest operations. There are two allowed operations. We may flip a single digit, changing 4 to 7 or 7 to 4.

codeforcescompetitive-programminggreedyimplementation
LeetCode 1868 - Product of Two Run-Length Encoded Arrays

This problem asks us to multiply two arrays that are already stored in run-length encoded form, without fully expanding them into normal arrays. A run-length encoded array stores consecutive repeated values compactly.

leetcodemediumarraytwo-pointers
LeetCode 3019 - Number of Changing Keys

The problem asks us to determine how many times a user changes keys while typing a string s. A change of key occurs when the current character typed differs in its lowercase form from the previous character typed.

leetcodeeasystring
LeetCode 2398 - Maximum Number of Robots Within Budget

This problem asks us to determine the maximum number of consecutive robots that can be run without exceeding a given budget. We are given two arrays of length n: chargeTimes and runningCosts.

leetcodehardarraybinary-searchqueuesliding-windowheap-(priority-queue)prefix-summonotonic-queue
LeetCode 2923 - Find Champion I

This problem describes a tournament of n teams, where every pair of teams has a clear winner. The input is given as a square matrix called grid, where grid[i][j] tells us whether team i is stronger than team j.

leetcodeeasyarraymatrix
LeetCode 3190 - Find Minimum Operations to Make All Elements Divisible by Three

The problem gives us an integer array nums. In one operation, we are allowed to either increase or decrease any single element by exactly 1. Our goal is to make every number in the array divisible by 3, while using the smallest possible number of operations.

leetcodeeasyarraymath
LeetCode 3029 - Minimum Time to Revert Word to Initial State I

The problem gives us a string word and an integer k. Every second, we are forced to perform two operations in sequence: 1. Remove the first k characters from the string. 2. Append any k characters to the end of the string. The appended characters are completely under our control.

leetcodemediumstringrolling-hashstring-matchinghash-function
LeetCode 2107 - Number of Unique Flavors After Sharing K Candies

The problem gives us an integer array candies, where each value represents the flavor of a candy. We must give exactly k consecutive candies to our sister. After removing those k candies, we keep the remaining candies for ourselves.

leetcodemediumarrayhash-tablesliding-window
LeetCode 3031 - Minimum Time to Revert Word to Initial State II

The problem requires simulating a repetitive transformation on a string word where, at each second, the first k characters are removed, and then any k characters are appended to the end.

leetcodehardstringrolling-hashstring-matchinghash-function
LeetCode 2887 - Fill Missing Data

The problem provides a Pandas DataFrame named products with three columns: | Column | Type | | --- | --- | | name | object | | quantity | int | | price | int | The task is to replace all missing values in the quantity column with 0.

leetcodeeasy
LeetCode 3001 - Minimum Moves to Capture The Queen

This problem gives us the positions of three chess pieces on a standard 8 x 8 chessboard: - A white rook at (a, b) - A white bishop at (c, d) - A black queen at (e, f) We are allowed to move only the white pieces. The queen remains stationary.

leetcodemediummathenumeration
LeetCode 2663 - Lexicographically Smallest Beautiful String

The problem requires generating the lexicographically smallest beautiful string that is strictly larger than a given beautiful string s. A string is beautiful if it uses only the first k letters of the English alphabet and contains no palindromic substring of length 2 or more.

leetcodehardstringgreedy