brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 416C - Booking System

We are given a collection of booking requests, where each request represents a group of guests who either all get seated together or do not come at all.

codeforcescompetitive-programmingbinary-searchdpgreedyimplementation
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 2609 - Find the Longest Balanced Substring of a Binary String

The problem gives us a binary string s, which means the string contains only the characters '0' and '1'. We need to find the length of the longest substring that is considered balanced. A substring is balanced when two conditions are satisfied: 1.

leetcodeeasystring
LeetCode 2324 - Product Sales Analysis IV

This problem asks us to analyze sales data to determine which products each user spent the most money on. We are given two tables: Sales and Product. The Sales table contains individual transactions, showing which user bought which product and in what quantity.

leetcodemediumdatabase
LeetCode 2411 - Smallest Subarrays With Maximum Bitwise OR

The problem asks us to find, for each index in a given array nums, the length of the shortest contiguous subarray starting at that index whose bitwise OR is equal to the maximum possible bitwise OR obtainable from that index onward.

leetcodemediumarraybinary-searchbit-manipulationsliding-window
LeetCode 3388 - Count Beautiful Splits in an Array

We are given an integer array nums, and we want to count how many ways we can split it into exactly three non-empty contiguous subarrays: - nums1 - nums2 - nums3 such that: where + means concatenation. A split is considered beautiful if at least one of these conditions holds: 1.

leetcodemediumarraydynamic-programming
LeetCode 1970 - Last Day Where You Can Still Cross

This problem asks us to find the last day we can cross a grid from the top row to the bottom row, walking only on land. The grid is initially all land (0), and each day, specific cells are flooded with water (1) according to the cells array.

leetcodehardarraybinary-searchdepth-first-searchbreadth-first-searchunion-findmatrix
CF 140F - New Year Snowflake

We are given a set of points on the plane representing the crystals that survived after part of a symmetric snowflake melted.

codeforcescompetitive-programminggeometrysortings
LeetCode 2402 - Meeting Rooms III

The problem is about scheduling meetings into a fixed number of rooms, where each meeting has a unique start time and a defined duration. We have n rooms numbered from 0 to n - 1, and we are given a list of meetings represented as [start, end) intervals.

leetcodehardarrayhash-tablesortingheap-(priority-queue)simulation
LeetCode 1878 - Get Biggest Three Rhombus Sums in a Grid

The problem asks us to compute the largest three distinct rhombus sums in a given m x n integer grid. A rhombus in this context is a square rotated 45 degrees, whose corners align with grid cells. The rhombus sum includes only the border cells of this shape, not the interior.

leetcodemediumarraymathsortingheap-(priority-queue)matrixprefix-sum
LeetCode 2221 - Find Triangular Sum of an Array

The problem asks us to compute the triangular sum of an array of digits. The triangular sum is obtained by repeatedly reducing the array according to a simple rule: for every pair of adjacent elements, sum them modulo 10 to form a new array of length one less than the current…

leetcodemediumarraymathsimulationcombinatoricsnumber-theory
CF 204A - Little Elephant and Interval

We are asked to count the numbers in a given interval [l, r] where the first digit equals the last digit. The input consists of two integers l and r, defining the interval. The output is a single integer, the count of numbers satisfying this property.

codeforcescompetitive-programmingbinary-searchcombinatoricsdp
LeetCode 2142 - The Number of Passengers in Each Bus I

This problem involves simulating passengers arriving at a bus station and boarding buses as they arrive. We are given two tables: Buses and Passengers. Each bus has a unique busid and an arrivaltime, and each passenger has a unique passengerid and an arrivaltime.

leetcodemediumdatabase
LeetCode 2729 - Check if The Number is Fascinating

The problem gives us a three digit integer n. We must determine whether n is a fascinating number. A number is considered fascinating when we concatenate three values together: 1. n 2. 2 n 3.

leetcodeeasyhash-tablemath
LeetCode 2237 - Count Positions on Street With Required Brightness

The problem describes a street represented by positions from 0 to n - 1. There are multiple street lamps, each defined by its position and range. A lamp at position p with range r illuminates all positions from max(0, p - r) to min(n - 1, p + r), inclusive.

leetcodemediumarrayprefix-sum
CF 191B - Demonstration

We are asked to determine the earliest square where the opposition can hold a demonstration given the interference of the city administration. There are n squares arranged by increasing distance from the city center, with square 1 being the most central.

codeforcescompetitive-programminggreedy
LeetCode 2352 - Equal Row and Column Pairs

The problem gives us a square matrix grid of size n x n, where every element is an integer. We need to count how many (row, column) pairs are exactly equal.

leetcodemediumarrayhash-tablematrixsimulation
LeetCode 3149 - Find the Minimum Cost Array Permutation

The problem presents an array nums of length n that is a permutation of integers from 0 to n - 1. We are asked to find a permutation perm of the same range [0, 1, 2, ...

leetcodehardarraydynamic-programmingbit-manipulationbitmask
CF 138D - World of Darkraft

We have a rectangular board where every cell contains one of three symbols. A move selects an active cell and disables cells along diagonals passing through it. The exact diagonals depend on the symbol. A cell marked L attacks the two diagonals with constant i + j.

codeforcescompetitive-programmingdpgames
CF 174B - File List

We are given one long string that originally consisted of several file names written back to back with no separators. Every valid file name must look like name.ext. The rules are strict. The part before the dot contains only lowercase letters and has length from 1 to 8.

codeforcescompetitive-programmingdpgreedyimplementation
LeetCode 1965 - Employees With Missing Information

The problem provides two relational tables, one named Employees and another named Salaries, both keyed by employeeid. Each employee may or may not appear in both tables. The Employees table contains the employee’s name, while the Salaries table contains the employee’s salary.

leetcodeeasydatabase
LeetCode 2118 - Build the Equation

The problem asks us to construct a polynomial equation from a database table called Terms. Each row in the table represents a single term in the equation, where power is the exponent of X and factor is the coefficient.

leetcodeharddatabase
LeetCode 2145 - Count the Hidden Sequences

The problem asks us to determine how many possible sequences of integers exist that match a given array of differences between consecutive elements, while staying within a specified inclusive range.

leetcodemediumarrayprefix-sum
CF 162I - Truncatable primes

We are given a single integer and must decide whether it satisfies a very specific prime property. A number is considered truncatable if every suffix formed by repeatedly removing the leftmost digit is still prime.

codeforcescompetitive-programming*special
LeetCode 2481 - Minimum Cuts to Divide a Circle

The problem asks for the minimum number of straight cuts required to divide a circle into n equal slices. A valid cut can either pass through the center and touch two points on the circle, or touch one point on the circle and pass through the center.

leetcodeeasymathgeometry
LeetCode 3111 - Minimum Rectangles to Cover Points

The problem gives us a collection of 2D points, where each point is represented as (xi, yi). We must cover every point using a set of rectangles. Each rectangle has a very special form: - Its bottom edge always lies on the x-axis, meaning the rectangle starts at y = 0.

leetcodemediumarraygreedysorting
LeetCode 3058 - Friends With No Mutual Friends

The Friends table represents an undirected friendship graph. Each row (userid1, userid2) means the two users are directly connected as friends. The problem asks us to find every friendship pair where the two users do not share any common friend.

leetcodemediumdatabase
LeetCode 2870 - Minimum Number of Operations to Make Array Empty

The problem gives us an array nums containing positive integers. In a single operation, we are allowed to remove either: - Exactly 2 equal elements, or - Exactly 3 equal elements. Our goal is to remove all elements from the array using the minimum possible number of operations.

leetcodemediumarrayhash-tablegreedycounting
LeetCode 2790 - Maximum Number of Groups With Increasing Length

We are given an array usageLimits where usageLimits[i] tells us how many times the number i can be used across all groups. The numbers available are exactly 0 through n - 1, where n is the length of the array.

leetcodehardarraymathbinary-searchgreedysorting
CF 153D - Date Change

We are asked to manipulate dates by adding or subtracting a number of days. The input consists of a date string in the "DD.MM.YYYY" format and an integer representing a shift in days, which can be positive or negative.

codeforcescompetitive-programming*special
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
CF 255B - Code Parsing

We are given a string consisting solely of the characters "x" and "y". Two operations can be applied repeatedly in a specific order. The first operation swaps a consecutive "y" followed by "x" into "x" then "y". The second operation removes a consecutive "x" followed by "y".

codeforcescompetitive-programmingimplementation
LeetCode 2516 - Take K of Each Character From Left and Right

The problem asks us to determine the minimum number of characters to take from either end of a string s consisting only of the letters 'a', 'b', and 'c' so that we collect at least k of each character.

leetcodemediumhash-tablestringsliding-window
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
CF 162F - Factorial zeros

The task is to determine how many trailing zeros appear at the end of the factorial of a given integer n. A factorial, denoted n!, is the product of all integers from 1 up to n.

codeforcescompetitive-programming*special
CF 245B - Internet Address

Vasya scribbled an Internet address in his notebook, but he was in a hurry and omitted all punctuation characters like :, /, and ..

codeforcescompetitive-programmingimplementationstrings
CF 245C - Game with Coins

We are given a line of numbered chests, each containing some number of coins. On each move, a player chooses an integer position $x$, and that move simultaneously affects three specific chests: $x$, $2x$, and $2x+1$. From each of these chests, one coin is removed if it exists.

codeforcescompetitive-programminggreedy
LeetCode 2512 - Reward Top K Students

The problem asks us to compute a ranking of students based on textual feedback they receive. We are given two lists of words: positivefeedback and negativefeedback.

leetcodemediumarrayhash-tablestringsortingheap-(priority-queue)
LeetCode 2719 - Count of Integers

The problem asks us to count how many integers lie between two given numeric strings num1 and num2 (inclusive) such that the sum of their digits is between minsum and maxsum.

leetcodehardmathstringdynamic-programming
CF 167C - Wizards and Numbers

We have a two-player game played with two numbers on a blackboard, call them a and b. Each player can, on their turn, either replace the larger number with the remainder of dividing it by the smaller number, or subtract a positive multiple of the smaller number from the larger…

codeforcescompetitive-programminggamesmath
LeetCode 2391 - Minimum Amount of Time to Collect Garbage

This problem models a garbage collection system with three separate garbage trucks: - One truck collects metal garbage, represented by 'M' - One truck collects paper garbage, represented by 'P' - One truck collects glass garbage, represented by 'G' The input array garbage…

leetcodemediumarraystringprefix-sum
CF 443A - Anton and Letters

We are given a single formatted string that represents a set of lowercase English letters. The set is written in a very specific textual form: it starts with an opening brace, ends with a closing brace, and inside the braces letters are listed separated by comma and space.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
LeetCode 3106 - Lexicographically Smallest String After Operations With Constraint

This problem asks us to transform a given string s into another string t such that the total transformation cost does not exceed k. Among all possible valid strings, we must return the lexicographically smallest one. The key detail is how the transformation cost is defined.

leetcodemediumstringgreedy
LeetCode 2318 - Number of Distinct Roll Sequences

The problem is asking us to compute the total number of distinct sequences of dice rolls of length n that satisfy two constraints: the greatest common divisor (GCD) of any two consecutive rolls must be 1, and any repeated value in the sequence must be separated by at least two…

leetcodeharddynamic-programmingmemoization
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 2353 - Design a Food Rating System

The problem is asking us to implement a food rating system that supports dynamic updates to the ratings of individual food items and allows querying for the highest-rated food for a given cuisine.

leetcodemediumarrayhash-tablestringdesignheap-(priority-queue)ordered-set
LeetCode 3299 - Sum of Consecutive Subsequences

We are given an array nums, and we must consider all non-empty subsequences of that array. A subsequence preserves the original order of elements, but elements do not need to be contiguous.

leetcodehardarrayhash-tabledynamic-programming
CF 161C - Abracadabra

The infinite string in this problem is built recursively. Start with: In general: The alphabet contains 36 symbols: The full string after 30 steps has length: $ For k = 30, the length is about 10^9, which matches the input bounds.

codeforcescompetitive-programmingdivide-and-conquer
LeetCode 1852 - Distinct Numbers in Each Subarray

The problem gives us an integer array nums and an integer k. For every contiguous subarray of length k, we must determine how many unique values appear inside that window. A subarray is a continuous portion of the array.

leetcodemediumarrayhash-tablesliding-window
LeetCode 2562 - Find the Array Concatenation Value

The problem is asking us to compute a special sum over a given array nums by repeatedly concatenating the first and last elements of the array until it is empty.

leetcodeeasyarraytwo-pointerssimulation
CF 401B - Sereja and Contests

The contest platform numbers every round consecutively by start time. A round can either be a standalone Div2 round, or a pair of simultaneous rounds where Div2 gets identifier i and Div1 gets identifier i + 1. Sereja only participates in Div2 rounds.

codeforcescompetitive-programminggreedyimplementationmath
LeetCode 2608 - Shortest Cycle in a Graph

The problem gives us an undirected graph with n vertices labeled from 0 to n - 1. The graph is represented using an edge list, where each edge connects two vertices in both directions. Our task is to find the length of the shortest cycle in the graph.

leetcodehardbreadth-first-searchgraph-theory
LeetCode 2375 - Construct Smallest Number From DI String

The problem asks us to construct the lexicographically smallest number from a string pattern consisting of 'I' and 'D'.

leetcodemediumstringbacktrackingstackgreedy
LeetCode 2419 - Longest Subarray With Maximum Bitwise AND

The problem asks us to find the length of the longest subarray within a given array nums such that the bitwise AND of all elements in that subarray is maximized.

leetcodemediumarraybit-manipulationbrainteaser
LeetCode 2485 - Find the Pivot Integer

The problem gives us a positive integer n and asks us to find a special integer x, called the pivot integer, such that: - The sum of all integers from 1 to x is equal to - The sum of all integers from x to n The important detail is that x belongs to both sums.

leetcodeeasymathprefix-sum
LeetCode 3036 - Number of Subarrays That Match a Pattern II

This guide will be very long, likely exceeding a single message cleanly while still maintaining the level of detail and formatting quality you requested for a reference document.

leetcodehardarrayrolling-hashstring-matchinghash-function
CF 413C - Jeopardy!

The game consists of n questions, each with some base value a[i]. Some questions are marked as auctions. Team R2 starts by choosing the first question. After that, whoever answered the previous question correctly gets to choose the next question.

codeforcescompetitive-programminggreedymath
LeetCode 2203 - Minimum Weighted Subgraph With the Required Paths

This problem gives us a weighted directed graph with n nodes and a list of directed edges. Each edge has a positive weight. We are also given two source nodes, src1 and src2, along with a destination node dest.

leetcodehardgraph-theoryheap-(priority-queue)shortest-path
LeetCode 2264 - Largest 3-Same-Digit Number in String

The problem requires identifying the largest "good" integer from a given string of digits. A "good" integer is defined as a substring of length 3 where all digits are identical.

leetcodeeasystring
CF 212D - Cutting a Fence

We are given a long strip of vertical planks, each with a fixed height. For any contiguous segment of planks of fixed length $k$, Vasya paints a rectangle whose height is determined by the shortest plank inside that segment.

codeforcescompetitive-programmingbinary-searchdata-structuresdsu
LeetCode 3210 - Find the Encrypted String

The problem asks us to implement a custom string encryption algorithm. We are given a string s and an integer k. For each character in s, we need to replace it with the character that is k positions ahead in the string, in a cyclic manner.

leetcodeeasystring
LeetCode 3318 - Find X-Sum of All K-Long Subarrays I

The problem asks us to compute a special value called the x-sum for every contiguous subarray of length k. For each window of size k, we first count how many times each number appears. After that, we only keep the contributions of the top x most frequent distinct values.

leetcodeeasyarrayhash-tablesliding-windowheap-(priority-queue)
CF 301D - Yaroslav and Divisors

We are given a permutation of numbers from 1 to n. For every query interval [l, r], we must count how many ordered pairs of positions (q, w) inside that interval satisfy: $$p[q] mid p[w]$$ Since all values are distinct and form a permutation, every number appears exactly once.

codeforcescompetitive-programmingdata-structures
LeetCode 3090 - Maximum Length Substring With Two Occurrences

The problem is asking for the maximum length of a substring in a given string s such that no character occurs more than twice within that substring. In other words, for any valid substring, each character can appear at most two times.

leetcodeeasyhash-tablestringsliding-window
LeetCode 2816 - Double a Number Represented as a Linked List

This problem asks us to double a number represented as a singly linked list. Each node of the list contains a single digit, and the digits are stored in the order from most significant to least significant. For example, the list [1,8,9] represents the number 189.

leetcodemediumlinked-listmathstack
CF 164A - Variable, or There and Back Again

We are given a directed graph where every node represents a program state. Each state does one of three things to a variable: 0 means the variable is ignored. 1 means the variable is assigned a new value. 2 means the variable is used.

codeforcescompetitive-programmingdfs-and-similargraphs
LeetCode 2864 - Maximum Odd Binary Number

The problem gives us a binary string s, containing only '0' and '1' characters. We are allowed to rearrange the bits in any order we want, but we must use exactly the same bits that appear in the original string.

leetcodeeasymathstringgreedy
LeetCode 2332 - The Latest Time to Catch a Bus

The problem asks us to determine the latest time we can arrive at a bus station to catch a bus, given the departure times of buses, arrival times of other passengers, and the maximum capacity of each bus.

leetcodemediumarraytwo-pointersbinary-searchsorting
LeetCode 1993 - Operations on Tree

The problem asks us to design a mutable tree-based data structure that supports three operations: lock, unlock, and upgrade. Each node in the tree may either be unlocked or locked by exactly one user. The operations must follow strict rules about when a node may change state.

leetcodemediumarrayhash-tabletreedepth-first-searchbreadth-first-searchdesign
LeetCode 2630 - Memoize II

The problem asks us to implement a memoized version of a given function fn. A memoized function is one that caches the results of previous calls and returns the cached result if the same inputs are passed again.

leetcodehard
LeetCode 3020 - Find the Maximum Number of Elements in Subset

The problem gives us an array of positive integers and asks us to choose the largest possible subset that can be rearranged into a very specific symmetric structure. The required structure looks like this: where is a power of two.

leetcodemediumarrayhash-tableenumeration
CF 157A - Game Outcome

We are given an n × n board where every cell contains an integer. For each cell, we compare two quantities. The first quantity is the sum of all numbers in that cell’s row. The second quantity is the sum of all numbers in that cell’s column.

codeforcescompetitive-programmingbrute-force
LeetCode 2733 - Neither Minimum nor Maximum

The problem asks us to select a number from an array of distinct positive integers such that the chosen number is neither the minimum nor the maximum in the array. In other words, we must return a number that lies strictly between the smallest and largest elements.

leetcodeeasyarraysorting
LeetCode 2172 - Maximum AND Sum of Array

This problem asks us to distribute a set of integers into numbered slots in a way that maximizes a scoring function based on bitwise AND operations.

leetcodehardarraydynamic-programmingbit-manipulationbitmask
CF 181B - Number of Triplets

We are given a set of distinct points on a 2D plane. The task is to count how many unordered triples of points form a configuration where one point lies exactly at the midpoint of the segment formed by the other two.

codeforcescompetitive-programmingbinary-searchbrute-force
CF 149D - Coloring Brackets

We are given a valid parenthesis sequence. Every opening bracket has a unique matching closing bracket, and the pairs are properly nested. We want to assign colors to brackets under two rules.

codeforcescompetitive-programmingdp
LeetCode 2539 - Count the Number of Good Subsequences

LeetCode 2539: Count the Number of Good Subsequences (Medium)

leetcodemediumhash-tablemathstringcombinatoricscounting
LeetCode 3097 - Shortest Subarray With OR at Least K II

This problem asks us to find the smallest non-empty contiguous subarray whose bitwise OR is at least k. The input consists of: - An integer array nums - An integer k For any subarray nums[left:right+1], we compute the bitwise OR of all elements inside that range.

leetcodemediumarraybit-manipulationsliding-window
LeetCode 1903 - Largest Odd Number in String

The problem asks us to find the largest-valued odd integer substring from a given string num that represents a large integer. Here, a substring is any contiguous sequence of characters in num.

leetcodeeasymathstringgreedy
LeetCode 3116 - Kth Smallest Amount With Single Denomination Combination

The problem asks us to determine the kth smallest amount that can be formed using coins of given denominations under a strict limitation: we can only use a single type of coin at a time. In other words, combinations of different denominations are not allowed.

leetcodehardarraymathbinary-searchbit-manipulationcombinatoricsnumber-theory
LeetCode 3283 - Maximum Number of Moves to Kill All Pawns

The problem gives us a 50 x 50 chessboard containing exactly one knight and up to 15 pawns. The knight starts at position (kx, ky), and every pawn is placed at one of the coordinates in positions. Two players, Alice and Bob, alternate turns. Alice moves first.

leetcodehardarraymathbit-manipulationbreadth-first-searchgame-theorybitmask
LeetCode 2605 - Form Smallest Number From Two Digit Arrays

The problem gives us two arrays, nums1 and nums2, where each array contains unique digits from 1 to 9. We need to construct the smallest possible number such that the number contains at least one digit from each array.

leetcodeeasyarrayhash-tableenumeration
LeetCode 2330 - Valid Palindrome IV

The problem gives us a string s containing only lowercase English letters. We are allowed to perform operations where we change any single character into any other lowercase character.

leetcodemediumtwo-pointersstring
LeetCode 2349 - Design a Number Container System

The problem asks us to design a data structure that supports two operations efficiently: 1. Assign a number to a given index. 2. Find the smallest index currently assigned to a given number.

leetcodemediumhash-tabledesignheap-(priority-queue)ordered-set
CF 144B - Meeting

We are asked to determine how many generals need warm blankets at a rectangular table placed on an infinite Cartesian plane. The table corners are given by two points with integer coordinates, and each integer point along the perimeter of the rectangle hosts a general.

codeforcescompetitive-programmingimplementation
LeetCode 2563 - Count the Number of Fair Pairs

The problem asks us to count how many pairs of indices (i, j) satisfy two conditions: 1. i < j 2. The sum nums[i] + nums[j] lies within the inclusive range [lower, upper] We are given an integer array nums and two bounds, lower and upper.

leetcodemediumarraytwo-pointersbinary-searchsorting
LeetCode 2258 - Escape the Spreading Fire

This problem asks us to determine how long we can safely wait before starting to move from the top-left corner of a grid to the bottom-right corner while a fire spreads across the grid over time.

leetcodehardarraybinary-searchbreadth-first-searchmatrix
LeetCode 3288 - Length of the Longest Increasing Path

We are given a collection of distinct points on a 2D plane. Each point is represented as (x, y). An increasing path is a sequence of points where both coordinates strictly increase from one point to the next.

leetcodehardarraybinary-searchsorting
LeetCode 3107 - Minimum Operations to Make Median of Array Equal to K

The problem asks us to transform an integer array so that its median becomes exactly k, using the minimum number of operations. In one operation, we may either increase or decrease any single element by 1. The median is defined after sorting the array in non-decreasing order.

leetcodemediumarraygreedysorting
LeetCode 2759 - Convert JSON String to Object

The problem asks us to take a JSON-formatted string str and convert it into the equivalent native data structure.

leetcodehard
LeetCode 3371 - Identify the Largest Outlier in an Array

The problem gives us an integer array nums containing exactly three types of elements: 1. n - 2 special numbers 2. One element equal to the sum of all special numbers 3. One outlier The task is to return the largest possible value that could serve as the outlier.

leetcodemediumarrayhash-tablecountingenumeration
LeetCode 3105 - Longest Strictly Increasing or Strictly Decreasing Subarray

The problem gives us an integer array nums and asks us to find the length of the longest contiguous subarray that is either strictly increasing or strictly decreasing. A subarray must consist of consecutive elements from the original array.

leetcodeeasyarray
CF 140A - New Year Table

We have a large circular table with radius R and want to place n identical circular plates, each with radius r. Every plate must satisfy three conditions simultaneously. First, the entire plate must stay inside the table. Second, every plate must touch the boundary of the table.

codeforcescompetitive-programminggeometrymath
CF 201D - Brand New Problem

Lesha has a problem description made of n distinct words, written in a fixed order. Each archive problem is another sequence of words, but archive descriptions may repeat words many times. We want to compare Lesha’s description against every archive description.

codeforcescompetitive-programmingbitmasksbrute-forcedp
LeetCode 2366 - Minimum Replacements to Sort the Array

The problem asks us to transform a given integer array nums into a non-decreasing array by performing a sequence of operations. In each operation, we are allowed to replace any single element with any two elements that sum to it.

leetcodehardarraymathgreedy
LeetCode 2262 - Total Appeal of A String

The problem asks us to calculate the total appeal of all substrings of a given string s. The appeal of a string is defined as the number of distinct characters it contains.

leetcodehardhash-tablestringdynamic-programming
LeetCode 2407 - Longest Increasing Subsequence II

The problem asks us to find the length of the longest subsequence in an integer array nums such that the subsequence is strictly increasing and the difference between consecutive elements does not exceed a given integer k.

leetcodehardarraydivide-and-conquerdynamic-programmingbinary-indexed-treesegment-treequeuemonotonic-queue
LeetCode 1850 - Minimum Adjacent Swaps to Reach the Kth Smallest Number

The problem asks us to compute the minimum number of adjacent swaps needed to transform a given number num into the kth smallest wonderful integer. A wonderful integer is any permutation of num's digits that is strictly greater than num.

leetcodemediumtwo-pointersstringgreedy
LeetCode 2475 - Number of Unequal Triplets in Array

The problem gives us a 0-indexed integer array nums, and we must count how many triplets (i, j, k) satisfy two conditions.

leetcodeeasyarrayhash-tablesorting
CF 202A - LLPS

We are given a lowercase string and must choose some characters, in order, to form a subsequence that is both a palindrome and lexicographically as large as possible. A subsequence does not need to stay contiguous.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcegreedyimplementationstrings