brain

tamnd's digital brain — notes, problems, research

42616 notes

CF 158A - Next Round

We are given the final standings of a programming contest. The scores are already sorted in non-increasing order, meaning each participant has a score greater than or equal to the next participant. A participant advances to the next round if two conditions are true.

codeforcescompetitive-programming*specialimplementation
LeetCode 2686 - Immediate Food Delivery III

This problem asks us to calculate the percentage of immediate food delivery orders for each unique orderdate. The Delivery table contains one row per order. Each row includes: - deliveryid: A unique identifier for the delivery. - customerid: The customer who placed the order.

leetcodemediumdatabase
CF 221A - Little Elephant and Function

We are given a recursive procedure that operates on a permutation of numbers from 1 to n. The function behaves like this: For f(x), it first recursively processes the first x - 1 elements, then swaps positions x - 1 and x.

codeforcescompetitive-programmingimplementationmath
LeetCode 3285 - Find Indices of Stable Mountains

The problem asks us to find indices of "stable" mountains from a given array of mountain heights. Each element in the array represents the height of a mountain in sequence.

leetcodeeasyarray
LeetCode 2953 - Count Complete Substrings

The problem asks us to count how many substrings of a given string are considered "complete". A substring is complete if it satisfies two conditions simultaneously: 1. Every distinct character in the substring appears exactly k times. 2.

leetcodehardhash-tablestringsliding-window
LeetCode 2699 - Modify Graph Edge Weights

You asked for a complete guide, but the previous message included two different LeetCode problems with full requirements: - LeetCode 2692 - Make Object Immutable - LeetCode 2699 - Modify Graph Edge Weights A full reference-quality guide for either one is quite large and should…

leetcodehardgraph-theoryheap-(priority-queue)shortest-path
CF 325A - Square and Rectangles

We are given up to five axis-aligned rectangles on a plane. Each rectangle is defined by its bottom-left and top-right coordinates. No two rectangles overlap, although they may touch at edges or corners.

codeforcescompetitive-programmingimplementation
CF 427A - Police Recruits

We are given a sequence of events happening in time order in a city. Each event is either the arrival of one or more new police recruits, or the occurrence of a crime. When recruits arrive, they increase the number of available officers.

codeforcescompetitive-programmingimplementation
LeetCode 1929 - Concatenation of Array

This problem asks us to take an input array nums of length n and produce a new array ans of length 2n where the first half of ans is identical to nums and the second half is also identical to nums. In other words, ans is formed by concatenating nums with itself.

leetcodeeasyarraysimulation
CF 144C - Anagram Search

We are asked to count the number of substrings of a string s that can be transformed into an anagram of a given string p. The string s can contain question marks ?, which can be replaced by any lowercase letter.

codeforcescompetitive-programmingimplementationstrings
LeetCode 2510 - Check if There is a Path With Equal Number of 0's And 1's

This problem asks us to determine if there exists a path in a binary matrix from the top-left corner (0, 0) to the bottom-right corner (m - 1, n - 1) such that the number of 0s visited along the path is equal to the number of 1s.

leetcodemediumarraydynamic-programmingmatrix
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
LeetCode 1999 - Smallest Greater Multiple Made of Two Digits

The problem asks us to find the smallest integer that satisfies three specific conditions. Given an integer k and two digits digit1 and digit2, we need an integer that is strictly larger than k, is a multiple of k, and consists only of the two given digits.

leetcodemediummathenumeration
LeetCode 3251 - Find the Count of Monotonic Pairs II

The problem asks us to count the number of ways we can split an array of positive integers, nums, into two arrays, arr1 and arr2, such that they satisfy a set of monotonic conditions.

leetcodehardarraymathdynamic-programmingcombinatoricsprefix-sum
LeetCode 3094 - Guess the Number Using Bitwise Questions II

Before I write the full guide, I want to confirm one detail: for LeetCode 3094 - Guess the Number Using Bitwise Questions II, there are no public input/output examples in the problem statement because it is an interactive problem.

leetcodemediumbit-manipulationinteractive
LeetCode 2778 - Sum of Squares of Special Elements

This problem asks us to compute the sum of squares of certain elements in an array, specifically the special elements. The array nums is 1-indexed, meaning the first element is at index 1 (not 0).

leetcodeeasyarrayenumeration
LeetCode 3229 - Minimum Operations to Make Array Equal to Target

The problem gives us two arrays, nums and target, both of the same length. We are allowed to perform operations on nums until it becomes exactly equal to target.

leetcodehardarraydynamic-programmingstackgreedymonotonic-stack
LeetCode 3286 - Find a Safe Walk Through a Grid

The problem requires determining whether there exists a path from the top-left corner (0, 0) to the bottom-right corner (m - 1, n - 1) in a binary m x n matrix grid, while maintaining a health value greater than or equal to 1.

leetcodemediumarraybreadth-first-searchgraph-theoryheap-(priority-queue)matrixshortest-path
LeetCode 1933 - Check if String Is Decomposable Into Value-Equal Substrings

The problem asks us to determine if a given string s, consisting solely of digits '0' through '9', can be split into consecutive value-equal substrings such that exactly one substring has length 2 and all remaining substrings have length 3.

leetcodeeasystring
CF 163A - Substring and Subsequence

We are given two strings, s and t, and we are asked to count how many distinct pairs (x, y) exist such that x is a substring of s, y is a subsequence of t, and x and y are equal as strings. The key distinction is in how “distinct” is defined.

codeforcescompetitive-programmingdp
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 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
CF 233A - Perfect Permutation

We need to construct a permutation of numbers from 1 to n with two conditions. The first condition is p[p[i]] = i for every position i. Applying the permutation twice must return us to the original index. This means every element points back to its partner.

codeforcescompetitive-programmingimplementationmath
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 2791 - Count Paths That Can Form a Palindrome in a Tree

I can do that, but the guide will be very long for a single chat response because your required format includes detailed prose, brute force and optimal approaches, proof sketch, Python and Go implementations, worked traces for every example, complexity analysis, comprehensive…

leetcodehardhash-tablebit-manipulationtreedepth-first-search
CF 424C - Magic Formulas

Codeforces 424C: Magic Formulas

codeforcescompetitive-programmingmath
LeetCode 2178 - Maximum Split of Positive Even Integers

The problem is asking us to take an input integer finalSum and split it into the maximum number of unique positive even integers such that their sum equals finalSum.

leetcodemediummathbacktrackinggreedy
LeetCode 3240 - Minimum Number of Flips to Make Binary Grid Palindromic II

We are given a binary matrix grid with m rows and n columns. Every cell contains either 0 or 1. We may flip any cell, meaning we can change 0 to 1 or 1 to 0. The goal is to perform the minimum number of flips such that two conditions become true simultaneously: 1.

leetcodemediumarraytwo-pointersmatrix
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 2158 - Amount of New Area Painted Each Day

This problem describes a painting scenario represented as a one-dimensional number line. Each element in the input array paint[i] = [starti, endi] represents the section that needs to be painted on the ith day.

leetcodehardarraysegment-treeordered-set
LeetCode 3351 - Sum of Good Subsequences

This problem asks us to compute the sum of all good subsequences in a given integer array nums. A subsequence is any sequence derived from nums by deleting zero or more elements without changing the order of the remaining elements.

leetcodehardarrayhash-tabledynamic-programming
CF 212B - Polycarpus is Looking for Good Substrings

We are given one long lowercase string s. For every query, we are also given a set of characters C. Among all substrings of s, we only care about those whose set of distinct characters is exactly C. From those substrings, we must count how many are maximal by inclusion.

codeforcescompetitive-programmingbitmaskshashingimplementation
CF 214A - System of Equations

We need to count how many non-negative integer pairs (a, b) satisfy two equations at the same time: - a² + b = n - a + b² = m The input gives the two target values n and m.

codeforcescompetitive-programmingbrute-force
LeetCode 3314 - Construct the Minimum Bitwise Array I

The problem asks us to construct an array ans from a given array nums of prime integers. For each element nums[i], we need to find the smallest integer ans[i] such that the bitwise OR of ans[i] and ans[i] + 1 equals nums[i]. Formally, ans[i] | (ans[i] + 1) == nums[i].

leetcodeeasyarraybit-manipulation
LeetCode 2760 - Longest Even Odd Subarray With Threshold

The problem asks us to find the length of the longest contiguous subarray in a given integer array nums that satisfies three specific conditions. First, the subarray must start with an even number.

leetcodeeasyarraysliding-window
CF 246E - Blood Cousins Return

We are given a rooted forest describing family relations. Every person has a name and at most one parent. Multiple roots are allowed because some people may have no ancestor at all.

codeforcescompetitive-programmingbinary-searchdata-structuresdfs-and-similardpsortings
LeetCode 1902 - Depth of BST Given Insertion Order

The problem gives us an array order that represents the exact sequence in which values are inserted into a binary search tree, usually abbreviated as BST. The array is a permutation of integers from 1 to n, which means every value appears exactly once and there are no duplicates.

leetcodemediumarraytreebinary-search-treebinary-treeordered-set
LeetCode 2825 - Make String a Subsequence Using Cyclic Increments

The problem gives us two lowercase strings, str1 and str2. We are allowed to perform at most one global operation on str1. During this operation, we may choose any subset of indices in str1, and increment the character at each chosen index by one alphabetically.

leetcodemediumtwo-pointersstring
LeetCode 2397 - Maximum Rows Covered by Columns

This problem asks us to maximize the number of rows covered in a binary matrix after selecting exactly numSelect columns. Each row is covered if all 1s in that row are located in the selected columns, or if the row contains only 0s.

leetcodemediumarraybacktrackingbit-manipulationmatrixenumeration
LeetCode 2590 - Design a Todo List

This problem asks us to design a small task management system, similar to a lightweight todo application. We need to implement a TodoList class that supports adding tasks, marking tasks as completed, retrieving all pending tasks for a user, and filtering pending tasks by tag.

leetcodemediumarrayhash-tablestringdesignsorting
CF 402D - Upgrading Array

We are given an array of positive integers and a set of "bad" prime numbers. Every other prime not in the bad set is implicitly "good." Each number in the array contributes to a total "beauty" score determined by its prime factorization.

codeforcescompetitive-programmingdpgreedymathnumber-theory
LeetCode 2222 - Number of Ways to Select Buildings

The problem asks us to count the number of ways to select exactly 3 buildings from a street represented as a binary string s, such that no two consecutive buildings among the selected ones have the same type. Here, 0 represents an office, and 1 represents a restaurant.

leetcodemediumstringdynamic-programmingprefix-sum
LeetCode 2798 - Number of Employees Who Met the Target

The problem asks us to determine how many employees in a company have worked at least a minimum number of hours, specified by target. We are given a 0-indexed array hours, where hours[i] represents the total hours worked by employee i.

leetcodeeasyarray
CF 163E - e-Government

We have a fixed set of surnames. Each surname can be either active or inactive. Initially every surname is active. The system must process three kinds of operations. A query +i activates the i-th surname. A query -i deactivates the i-th surname. A query ?

codeforcescompetitive-programmingdata-structuresdfs-and-similardpstringstrees
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
LeetCode 2832 - Maximal Range That Each Element Is Maximum in It

We are given an array nums consisting of distinct integers. For every position i, we need to determine the maximum possible length of a contiguous subarray in which nums[i] is the largest element. More formally, for each index i, we want to find the longest subarray nums[l..

leetcodemediumarraystackmonotonic-stack
CF 432A - Choosing Teams

We are given a set of students at a university, each with a record of how many times they have already participated in the ACM ICPC world championship.

codeforcescompetitive-programminggreedyimplementationsortings
LeetCode 2022 - Convert 1D Array Into 2D Array

The problem asks us to transform a one-dimensional array, original, into a two-dimensional array with m rows and n columns.

leetcodeeasyarraymatrixsimulation
LeetCode 2611 - Mice and Cheese

The problem gives us two arrays, reward1 and reward2, where each index represents a specific type of cheese. Every cheese must be eaten by exactly one of the two mice. If cheese i is eaten by the first mouse, we gain reward1[i] points.

leetcodemediumarraygreedysortingheap-(priority-queue)
LeetCode 2176 - Count Equal and Divisible Pairs in an Array

The problem gives us a 0-indexed integer array nums and an integer k. We need to count how many pairs of indices (i, j) satisfy all of the following conditions: 1. 0 <= i < j < n 2. nums[i] == nums[j] 3.

leetcodeeasyarray
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
CF 178A1 - Educational Game

We have an array of non-negative integers. In one move, we choose an index i with a[i] 0, decrease a[i] by one, and increase some position i + 2t by one. The destination index must have the same parity as i, because the distance moved is always even.

codeforcescompetitive-programming
CF 251C - Number Transformation

Codeforces 251C: Number Transformation

codeforcescompetitive-programmingdpgreedynumber-theory
LeetCode 3066 - Minimum Operations to Exceed Threshold Value II

This problem asks us to repeatedly combine the two smallest elements of an array nums until all elements are greater than or equal to a threshold value k. The combination operation is not a simple sum, but a formula: min(x, y) 2 + max(x, y).

leetcodemediumarrayheap-(priority-queue)simulation
LeetCode 2351 - First Letter to Appear Twice

The problem gives us a string s containing only lowercase English letters. We need to return the first letter whose second occurrence appears earliest in the string. This detail is extremely important.

leetcodeeasyhash-tablestringbit-manipulationcounting
CF 167A - Wizards and Trolleybuses

Each trolleybus starts from the depot at a fixed departure time. It begins with speed 0, can accelerate at most a, and can never exceed its own speed limit v[i]. The destination is d meters away.

codeforcescompetitive-programmingimplementationmath
CF 260C - Balls and Boxes

We are given the final state of a row of boxes after a very specific operation was applied exactly once in reverse history. Originally, each box contained some number of balls.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
LeetCode 2943 - Maximize Area of Square Hole in Grid

The grid is formed by n + 2 horizontal bars and m + 2 vertical bars. These bars divide the plane into unit squares. The bars are numbered starting from 1. Some horizontal bars listed in hBars may be removed, and some vertical bars listed in vBars may also be removed.

leetcodemediumarraysorting
LeetCode 2674 - Split a Circular Linked List

The problem asks us to take a circular linked list of positive integers and split it into two separate circular linked lists. The first list should contain the first half of the nodes, rounded up (ceil(length / 2)), and the second list should contain the remaining nodes.

leetcodemediumlinked-listtwo-pointers
LeetCode 2800 - Shortest String That Contains Three Strings

The problem asks us to construct a string that contains three given strings a, b, and c as substrings while minimizing its length. If multiple strings satisfy the minimum length condition, the lexicographically smallest one must be returned.

leetcodemediumstringgreedyenumeration
LeetCode 2840 - Check if Strings Can be Made Equal With Operations II

The problem asks us to determine whether two strings s1 and s2 of equal length can be made identical using a specific type of swap operation.

leetcodemediumhash-tablestringsorting
LeetCode 2736 - Maximum Sum Queries

We are given two arrays, nums1 and nums2, both of length n. Each index j represents a point: and has an associated value: For every query [xi, yi], we must find an index j such that: and Among all indices satisfying both constraints, we want the maximum possible value: If no…

leetcodehardarraybinary-searchstackbinary-indexed-treesegment-treesortingmonotonic-stack
LeetCode 2454 - Next Greater Element IV

The problem asks us to compute, for every element in the array, its "second greater element" to the right. For an index i, we are interested in elements positioned after i. Among those elements, we only care about values strictly greater than nums[i].

leetcodehardarraybinary-searchstacksortingheap-(priority-queue)monotonic-stack
LeetCode 2795 - Parallel Execution of Promises for Individual Results Retrieval

This problem asks us to implement a function similar to JavaScript's Promise.allSettled(), but without actually using the built-in method. We are given an array of functions functions, where each function, when invoked, returns a promise.

leetcodemedium
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 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
LeetCode 2504 - Concatenate the Name and the Profession

The problem asks us to transform data in a SQL table named Person. Each row represents a person, with three columns: personid, name, and profession.

leetcodeeasydatabase
LeetCode 3319 - K-th Largest Perfect Subtree Size in Binary Tree

We are given the root of a binary tree and an integer k. Our goal is to find the size of the k-th largest perfect binary subtree contained anywhere within the tree. A perfect binary tree has two defining properties: 1. Every internal node has exactly two children. 2.

leetcodemediumtreedepth-first-searchsortingbinary-tree
LeetCode 2811 - Check if it is Possible to Split Array

The problem asks whether it is possible to split an input array nums into exactly n arrays of size one using a series of valid splits. Each split must take an existing array of length at least two and divide it into two good arrays.

leetcodemediumarraydynamic-programminggreedy
LeetCode 2088 - Count Fertile Pyramids in a Land

The problem gives us a binary matrix where each cell represents a piece of land. A value of 1 means the land is fertile, while 0 means barren. We need to count every valid pyramidal plot and inverse pyramidal plot formed entirely from fertile cells.

leetcodehardarraydynamic-programmingmatrix
LeetCode 2313 - Minimum Flips in Binary Tree to Get Result

The problem presents a binary tree where leaf nodes represent boolean values 0 (false) or 1 (true), and internal nodes represent boolean operations OR, AND, XOR, and NOT, encoded as integers 2, 3, 4, and 5. You are also given a target boolean result.

leetcodeharddynamic-programmingtreedepth-first-searchbinary-tree
LeetCode 2006 - Count Number of Pairs With Absolute Difference K

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

leetcodeeasyarrayhash-tablecounting
CF 406E - Hamming Triples

The problem presents a collection of binary strings of a fixed length, but rather than giving the strings explicitly, each string is described compactly: the first $fi$ bits are the same, $si$, and the remaining $n-fi$ bits are the opposite of $si$.

codeforcescompetitive-programmingimplementationmathtwo-pointers
LeetCode 2735 - Collecting Chocolates

The problem gives us an array nums, where nums[i] represents the cost of buying a chocolate currently located at index i. Initially, the chocolate at index i is also considered to be of type i. Since there are n positions, there are exactly n chocolate types.

leetcodemediumarrayenumeration
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
CF 173E - Camping Groups

We are asked to partition a club of members into groups based on responsibility and age constraints. Each member has a responsibility value and an age.

codeforcescompetitive-programmingdata-structuressortings
LeetCode 3120 - Count the Number of Special Characters I

The problem asks us to count the number of special characters in a given string word. A character is defined as special if it appears in both lowercase and uppercase forms within the same string.

leetcodeeasyhash-tablestring
LeetCode 2768 - Number of Black Blocks

This problem asks us to count the number of 2 x 2 blocks in a grid based on how many black cells they contain. We are given the dimensions of a grid, m rows and n columns, and a list of coordinates representing black cells. Every cell not listed is white.

leetcodemediumarrayhash-tableenumeration
LeetCode 3256 - Maximum Value Sum by Placing Three Rooks I

We are given an m x n matrix called board, where each cell contains an integer value. We must place exactly three rooks on the board. A rook attacks every square in the same row and the same column.

leetcodehardarraydynamic-programmingmatrixenumeration
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 1804 - Implement Trie II (Prefix Tree)

This problem asks us to implement a Trie data structure, also known as a prefix tree, which is designed to store strings efficiently in a way that allows fast lookups and prefix queries. We are required to implement the following operations: 1.

leetcodemediumhash-tablestringdesigntrie
LeetCode 3212 - Count Submatrices With Equal Frequency of X and Y

The problem asks us to count submatrices within a given 2D character matrix grid that satisfy three conditions. A submatrix is defined by a contiguous rectangle within the grid, and the submatrix must include the top-left cell grid[0][0].

leetcodemediumarraymatrixprefix-sum
LeetCode 2899 - Last Visited Integers

The problem gives us an integer array nums that contains either positive integers or the value -1. We process the array from left to right while maintaining two conceptual arrays: - seen, which stores previously encountered positive integers - ans, which stores the answers for…

leetcodeeasyarraysimulation
LeetCode 2298 - Tasks Count in the Weekend

This problem provides a database table named Tasks, where each row represents a submitted task. Every task contains three fields: - taskid, the unique identifier for the task - assigneeid, the user assigned to the task - submitdate, the date the task was submitted The goal is…

leetcodemediumdatabase
LeetCode 3337 - Total Characters in String After Transformations II

The problem defines a repeated string transformation process over lowercase English letters. Every character does not simply become one new character, instead it expands into multiple characters depending on the value stored in nums.

leetcodehardhash-tablemathstringdynamic-programmingcounting
LeetCode 2253 - Dynamic Unpivoting of a Table

This problem asks us to transform a wide table into a normalized row-based format. The database table Products contains one row per product, and each store has its own dedicated column. The value inside a store column represents the product's price in that store.

leetcodeharddatabase
CF 204C - Little Elephant and Furik and Rubik

We are given two strings of equal length. From each string we independently pick a substring, and both substrings must have the same length. After choosing them, we compare them character by character and count how many positions match.

codeforcescompetitive-programmingmathprobabilities
LeetCode 2799 - Count Complete Subarrays in an Array

The problem asks us to count the number of complete subarrays in a given array nums. A subarray is complete if it contains all distinct elements that exist in the entire array.

leetcodemediumarrayhash-tablesliding-window
LeetCode 3079 - Find the Sum of Encrypted Integers

The problem provides an array of positive integers nums and asks us to compute a sum based on an encryption transformation. The transformation encrypt(x) replaces every digit in x with the largest digit in x.

leetcodeeasyarraymath
LeetCode 1918 - Kth Smallest Subarray Sum

The problem asks us to find the kth smallest sum among all possible non-empty contiguous subarrays of a given integer array nums. Each subarray is formed by taking a contiguous sequence of elements from nums, and its sum is the sum of the elements in that subarray.

leetcodemediumarraybinary-searchsliding-window
LeetCode 2738 - Count Occurrences in Text

The problem asks us to analyze a database table named Files that contains two columns: filename and content. Each row corresponds to a unique file and its textual content.

leetcodemediumdatabase
LeetCode 3127 - Make a Square with the Same Color

This problem gives us a fixed 3 x 3 grid containing only two possible characters, 'B' for black and 'W' for white. We are allowed to change the color of at most one cell.

leetcodeeasyarraymatrixenumeration
LeetCode 2991 - Top Three Wineries

The problem asks us to determine the top three wineries in each country based on the total points accumulated by each winery. We are given a table called Wineries that contains columns id, country, points, and winery.

leetcodeharddatabase
LeetCode 2430 - Maximum Deletions on a String

The problem gives us a string s consisting only of lowercase English letters. We want to completely delete the string using the maximum possible number of operations. In a single operation, we have two possible actions: 1. Delete the entire remaining string immediately. 2.

leetcodehardstringdynamic-programmingrolling-hashstring-matchinghash-function
LeetCode 2266 - Count Number of Texts

The problem requires determining how many possible text messages Alice could have sent given a sequence of digit key presses received by Bob. Each digit from '2' to '9' maps to a set of letters on a phone keypad.

leetcodemediumhash-tablemathstringdynamic-programming
LeetCode 3169 - Count Days Without Meetings

The problem gives us a total number of working days, numbered from 1 to days, along with a list of meeting intervals. Each interval [start, end] represents a meeting that occupies every day from start through end, inclusive.

leetcodemediumarraysorting
LeetCode 3254 - Find the Power of K-Size Subarrays I

The problem asks us to examine every contiguous subarray of length k in the input array nums and determine its "power". A subarray has valid power only if two conditions are simultaneously true: 1. The elements are sorted in strictly ascending order. 2.

leetcodemediumarraysliding-window
LeetCode 2079 - Watering Plants

This problem asks us to simulate watering a row of plants with a watering can that has a fixed capacity. The plants are arranged along a straight line with indices representing their positions.

leetcodemediumarraysimulation
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
CF 183E - Candy Shop

There are n kids sitting in a fixed cyclic order. During the buying process, the chosen package sizes must form a strictly increasing sequence globally across all turns. After kid n, the next turn goes back to kid 1.

codeforcescompetitive-programminggreedy