brain

tamnd's digital brain — notes, problems, research

42617 notes

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 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 1975 - Maximum Matrix Sum

The problem gives an n x n integer matrix and allows an operation where we pick any two adjacent cells (sharing a side) and multiply both values by -1.

leetcodemediumarraygreedymatrix
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 2343 - Query Kth Smallest Trimmed Number

This problem provides a list of numbers represented as strings, all of equal length. The task is to answer multiple queries, where each query asks for the index of the k-th smallest number after trimming every number in the list to its last trimi digits.

leetcodemediumarraystringdivide-and-conquersortingheap-(priority-queue)radix-sortquickselect
CF 155A - I_love_\%username\%

We are given the chronological contest scores of one programmer. A performance is called "amazing" when the current score is strictly greater than every previous score, or strictly smaller than every previous score.

codeforcescompetitive-programmingbrute-force
LeetCode 2368 - Reachable Nodes With Restrictions

That is a large, highly structured guide. To make sure I target the exact problem and keep the response complete in a single message, can you confirm you want the full solution guide for LeetCode 2368 - Reachable Nodes With Restrictions?

leetcodemediumarrayhash-tabletreedepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 2862 - Maximum Element-Sum of a Complete Subset of Indices

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

leetcodehardarraymathnumber-theory
CF 153C - Caesar Cipher

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

codeforcescompetitive-programming*special
LeetCode 2271 - Maximum White Tiles Covered by a Carpet

That is a long-form reference guide request. To avoid truncation and keep the formatting exact, I will provide the complete solution guide for LeetCode 2271 in a single structured response.

leetcodemediumarraybinary-searchgreedysliding-windowsortingprefix-sum
LeetCode 2394 - Employees With Deductions

This problem asks us to identify employees whose monthly working time is less than the required number of hours. Each employee has a minimum number of hours they must work during October 2022 to avoid salary deductions.

leetcodemediumdatabase
LeetCode 2063 - Vowels of All Substrings

The problem asks us to compute the total number of vowels that appear across every possible substring of a given string. A substring is any contiguous sequence of characters. For a string of length n, there are n (n + 1) / 2 total substrings.

leetcodemediummathstringdynamic-programmingcombinatorics
LeetCode 2205 - The Number of Users That Are Eligible for Discount

The problem gives us a table named Purchases, where each row represents a purchase made by a user. Every record contains three fields: - userid, identifying the customer - timestamp, indicating when the purchase happened - amount, representing how much money was spent The pair…

leetcodeeasydatabase
LeetCode 2303 - Calculate Amount Paid in Taxes

This problem is asking us to simulate a progressive tax system. We are given a list of tax brackets where each bracket specifies an upper bound of income and a tax percentage.

leetcodeeasyarraysimulation
LeetCode 2793 - Status of Flight Tickets

This problem asks us to determine whether each passenger's ticket is confirmed or placed on the waitlist, based on the booking order and the capacity of the flight they booked.

leetcodehard
LeetCode 2165 - Smallest Value of the Rearranged Number

In this problem, we are given an integer num, which may be positive, negative, or zero. Our goal is to rearrange its digits so that the resulting number is as small as possible while preserving the original sign. The important detail is that the sign cannot change.

leetcodemediummathsorting
LeetCode 2226 - Maximum Candies Allocated to K Children

This problem asks us to determine the largest number of candies that every child can receive equally, given a collection of candy piles and a number of children k. We are given an integer array candies, where candies[i] represents the size of the i-th pile.

leetcodemediumarraybinary-search
LeetCode 2974 - Minimum Number Game

The problem gives us an integer array nums with an even number of elements. We repeatedly simulate a game between Alice and Bob until the array becomes empty. In each round, the following sequence happens: 1. Alice removes the smallest remaining number. 2.

leetcodeeasyarraysortingheap-(priority-queue)simulation
LeetCode 2702 - Minimum Operations to Make Numbers Non-positive

In this problem, we are given an array nums and two integers x and y, where x y. During each operation, we choose one index i and apply two different decrements: - nums[i] decreases by x - every other element decreases by y The goal is to determine the minimum number of…

leetcodehardarraybinary-search
CF 216B - Forming Teams

We can model the students as an undirected graph. Each student is a vertex, and every pair of enemies creates an edge. We want to split the remaining students into two teams of equal size such that no edge stays inside one team.

codeforcescompetitive-programmingdfs-and-similarimplementation
CF 196B - Infinite Maze

We are given a finite maze of size n × m. Some cells are walls, some are open, and one cell contains the starting position S. The maze is not used only once.

codeforcescompetitive-programmingdfs-and-similargraphs
LeetCode 2335 - Minimum Amount of Time to Fill Cups

The problem gives us an array amount of length 3. Each index represents the number of cups that need to be filled for a specific water type: - amount[0] represents cold water cups - amount[1] represents warm water cups - amount[2] represents hot water cups Every second, the…

leetcodeeasyarraygreedysortingheap-(priority-queue)
LeetCode 2901 - Longest Unequal Adjacent Groups Subsequence II

The problem asks us to select the longest subsequence of words from a given array such that adjacent words in the subsequence satisfy two conditions: first, their corresponding groups values are different, and second, the words are of the same length and differ by exactly one…

leetcodemediumarraystringdynamic-programming
LeetCode 2645 - Minimum Additions to Make Valid String

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

leetcodemediumstringdynamic-programmingstackgreedy
LeetCode 2680 - Maximum OR

In this problem, we are given an integer array nums and an integer k. We may perform at most k operations, where each operation selects one element and multiplies it by 2. Multiplying by 2 in binary is equivalent to shifting all bits one position to the left.

leetcodemediumarraygreedybit-manipulationprefix-sum
LeetCode 1946 - Largest Number After Mutating Substring

This problem asks us to construct the lexicographically largest possible numeric string after optionally applying a single transformation operation on one contiguous substring of the input string num.

leetcodemediumarraystringgreedy
LeetCode 2648 - Generate Fibonacci Sequence

The problem asks us to implement a generator function that yields numbers from the Fibonacci sequence. The Fibonacci sequence is defined recursively as Xn = Xn-1 + Xn-2 with the starting values X0 = 0 and X1 = 1.

leetcodeeasy
LeetCode 3307 - Find the K-th Character in String Game II

The problem describes a string manipulation game between Alice and Bob. Initially, Alice starts with a string word = "a". Bob provides a list of operations, represented by the integer array operations.

leetcodehardmathbit-manipulationrecursion
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
CF 417C - Football

We are asked to construct a complete record of matches between n teams, where every match has a winner and a loser, and no pair of teams plays more than once.

codeforcescompetitive-programmingconstructive-algorithmsgraphsimplementation
LeetCode 2969 - Minimum Number of Coins for Fruits II

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

leetcodehardarraydynamic-programmingqueueheap-(priority-queue)monotonic-queue
LeetCode 2344 - Minimum Deletions to Make Array Divisible

The problem gives us two arrays of positive integers, nums and numsDivide. We are allowed to delete any number of elements from nums, and our goal is to make the smallest remaining element in nums divide every number in numsDivide.

leetcodehardarraymathsortingheap-(priority-queue)number-theory
LeetCode 2296 - Design a Text Editor

This problem asks us to design a simplified text editor that supports four operations: 1. Inserting text at the current cursor position 2. Deleting characters to the left of the cursor 3. Moving the cursor left 4.

leetcodehardlinked-liststringstackdesignsimulationdoubly-linked-list
LeetCode 2959 - Number of Possible Sets of Closing Branches

This problem asks us to determine the number of possible sets of branches that can be closed such that the maximum distance between any pair of remaining open branches does not exceed a given maxDistance.

leetcodehardbit-manipulationgraph-theoryheap-(priority-queue)enumerationshortest-path
LeetCode 3160 - Find the Number of Distinct Colors Among the Balls

The problem gives us limit + 1 balls labeled from 0 to limit. Initially, none of the balls have a color assigned. We then process a sequence of queries, where each query is of the form [x, y]. This means ball x should now be painted with color y.

leetcodemediumarrayhash-tablesimulation
LeetCode 2787 - Ways to Express an Integer as Sum of Powers

This problem asks us to count how many different ways we can represent a given integer n as the sum of distinct positive integers raised to the power x.

leetcodemediumdynamic-programming
LeetCode 3341 - Find Minimum Time to Reach Last Room I

The problem is asking for the minimum time required to reach the bottom-right room (n - 1, m - 1) in a dungeon represented as an n x m grid. Each room (i, j) has a moveTime[i][j], which specifies the earliest time at which the room can be entered.

leetcodemediumarraygraph-theoryheap-(priority-queue)matrixshortest-path
LeetCode 2225 - Find Players With Zero or One Losses

The problem gives us a list of match results. Each match is represented as a pair: This means the player winner defeated the player loser. Our goal is to return two separate lists: 1. All players who never lost any match. 2. All players who lost exactly one match.

leetcodemediumarrayhash-tablesortingcounting
LeetCode 2593 - Find Score of an Array After Marking All Elements

Here is a comprehensive, detailed technical solution guide for LeetCode 2593 - Find Score of an Array After Marking All Elements, following your requested format precisely. The problem provides an array of positive integers, nums.

leetcodemediumarrayhash-tablesortingheap-(priority-queue)simulation
CF 413B - Spyke Chatting

We are given a company where employees participate in several independent chat groups. Each chat has a fixed membership defined in advance. Over time, a log records messages: each event says that a particular employee posts in a particular chat.

codeforcescompetitive-programmingimplementation
CF 427C - Checkposts

We are given a directed graph where each node represents a city junction, and each directed edge represents a one-way road. Each junction has a cost to build a police checkpost.

codeforcescompetitive-programmingdfs-and-similargraphstwo-pointers
LeetCode 2543 - Check if Point Is Reachable

The problem gives us an infinite two dimensional grid and asks whether we can travel from the starting point (1, 1) to a target point (targetX, targetY) using a specific set of operations.

leetcodehardmathnumber-theory
LeetCode 2539 - Count the Number of Good Subsequences

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

leetcodemediumhash-tablemathstringcombinatoricscounting
LeetCode 2438 - Range Product Queries of Powers

The problem defines a special array called powers. This array is built from the binary representation of n. Every positive integer can be uniquely represented as a sum of powers of two.

leetcodemediumarraybit-manipulationprefix-sum
CF 304A - Pythagorean Theorem II

We need to count how many integer-sided right triangles exist such that all three sides are at most n. A right triangle with sides (a, b, c) satisfies the Pythagorean equation: $a^2+b^2=c^2$$a$$b$$c = sqrt{a^2 + b^2} approx 21.21$$a^2 + b^2 = c^2 approx 225.00 + 225.00 = 450.

codeforcescompetitive-programmingbrute-forcemath
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 2494 - Merge Overlapping Events in the Same Hall

The problem requires us to merge overlapping events in the same hall. Each row of the HallEvents table represents an event in a particular hall with a startday and an endday. Events are considered overlapping if they share at least one day in common.

leetcodeharddatabase
LeetCode 2039 - The Time When the Network Becomes Idle

This problem involves a network of servers where server 0 is the master and all other servers are data servers. Each data server initially sends a message to the master, and the master instantly responds upon receiving the message.

leetcodemediumarraybreadth-first-searchgraph-theory
LeetCode 2109 - Adding Spaces to a String

The problem requires us to insert spaces into a given string s at specific positions described by the array spaces. Each element in spaces represents an index in the string before which a space should be inserted.

leetcodemediumarraytwo-pointersstringsimulation
LeetCode 2888 - Reshape Data: Concatenate

The problem is asking us to vertically concatenate two DataFrames into a single unified DataFrame. In simpler terms, given two tables df1 and df2 with identical columns and types, we need to stack the rows of df2 below the rows of df1.

leetcodeeasy
LeetCode 2897 - Apply Operations on Array to Maximize Sum of Squares

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

leetcodehardarrayhash-tablegreedybit-manipulation
LeetCode 2288 - Apply Discount to Prices

The problem asks us to process a string representing a sentence containing words and prices, where prices are words that start with a dollar sign 1e5 or 5$) should remain unchanged.

leetcodemediumstring
LeetCode 3315 - Construct the Minimum Bitwise Array II

We are given an array nums where every element is a prime number. For each value nums[i], we must find the smallest non-negative integer ans[i] such that: where | denotes the bitwise OR operation. If no such value exists, we must place -1 in the answer array at that position.

leetcodemediumarraybit-manipulation
LeetCode 2728 - Count Houses in a Circular Street

The problem asks us to determine the number of houses on a circular street where we can only interact with the street through the provided Street interface. Each house has a door that can either be open or closed.

leetcodeeasyarrayinteractive
LeetCode 2711 - Difference of Number of Distinct Values on Diagonals

The problem is asking us to compute a new matrix answer based on a given m x n grid, where each cell in answer represents the absolute difference between the number of distinct elements on the diagonal above and to the left of the current cell, and the number of distinct…

leetcodemediumarrayhash-tablematrix
LeetCode 2115 - Find All Possible Recipes from Given Supplies

This problem asks us to determine which recipes can be created when we start with a set of available supplies and are allowed to recursively create additional recipes. Each recipe has a list of required ingredients.

leetcodemediumarrayhash-tablestringgraph-theorytopological-sort
LeetCode 2990 - Loan Types

The problem requires identifying users who have taken both a "Refinance" loan and a "Mortgage" loan. The input is a table Loans containing loanid, userid, and loantype. Each row represents one loan taken by a user, and loanid is unique.

leetcodeeasydatabase
LeetCode 3253 - Construct String with Minimum Cost (Easy)

=== 1996-N5 === Origin: ROM Let denote the set of nonnegative integers. Find a bijective function from into such that for all , We first observe that the given functional equation is equivalent to This gives us the idea of introducing a function defined as By the above…

leetcodemedium
CF 199A - Hexadecimal's theorem

We are given a single integer n, and the statement guarantees that n itself is a Fibonacci number. The task is to represent n as the sum of three Fibonacci numbers.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementationnumber-theory
LeetCode 2316 - Count Unreachable Pairs of Nodes in an Undirected Graph

The problem asks us to find the number of pairs of nodes in an undirected graph that cannot reach each other via any path. You are given an integer n representing the total number of nodes labeled from 0 to n - 1 and a list of edges representing connections between nodes.

leetcodemediumdepth-first-searchbreadth-first-searchunion-findgraph-theory
CF 164E - Polycarpus and Tasks

Polycarpus has a sequence of tasks, each with a start window, an end window, and a duration. Formally, task i is represented by (li, ri, ti).

codeforcescompetitive-programming
LeetCode 3365 - Rearrange K Substrings to Form Target String

This problem asks whether it is possible to rearrange k contiguous equal-length substrings of a string s to form another string t, given that s and t are anagrams.

leetcodemediumhash-tablestringsorting
LeetCode 3358 - Books with NULL Ratings

This problem provides a database table named books. Each row in the table represents a single book and contains information such as the book's ID, title, author, publication year, and rating. The important detail is that the rating column can contain NULL values.

leetcodeeasydatabase
LeetCode 1996 - The Number of Weak Characters in the Game

In this problem, every character in the game has two attributes: - attack - defense The input is a 2D array called properties, where: represents the stats of the i-th character.

leetcodemediumarraystackgreedysortingmonotonic-stack
CF 303E - Random Ranking

Each participant receives a real-valued score chosen uniformly from an interval $[li, ri]$. Scores are independent. After all scores are generated, participants are sorted by score. Smaller score means better rank, so the participant with the largest score finishes last.

codeforcescompetitive-programmingdpmathprobabilities
CF 250C - Movie Critics

We are given a sequence of movie genres scheduled over n days, with exactly one movie per day. There are k genres, and each genre appears at least once. Valentine, a critic, experiences stress whenever the genre of consecutive movies he watches changes.

codeforcescompetitive-programminggreedy
LeetCode 3126 - Server Utilization Time

This problem provides a table named Servers that records status changes for multiple servers over time. Each row contains three values: - serverid, which identifies the server - statustime, which indicates when the status change occurred - sessionstatus, which is either…

leetcodemediumdatabase
LeetCode 2920 - Maximum Points After Collecting Coins From All Nodes

We are given a tree with n nodes rooted at node 0. Each node contains a certain number of coins. We must collect coins from every node while respecting the tree hierarchy, meaning a node can only be processed after all of its ancestors have already been processed.

leetcodehardarraydynamic-programmingbit-manipulationtreedepth-first-searchmemoization
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
CF 306B - Optimizer

We are given a linear memory array of size n and a set of m instructions, each of which sets a contiguous block of memory to the value 13. The instructions are indexed in the input order. Some instructions may overlap, fully or partially, with others.

codeforcescompetitive-programmingdata-structuresgreedysortings
LeetCode 1900 - The Earliest and Latest Rounds Where Players Compete

The tournament is organized as a sequence of elimination rounds. In every round, players are paired symmetrically from the two ends of the current lineup. The first player faces the last player, the second player faces the second-to-last player, and so on.

leetcodeharddynamic-programmingmemoization
LeetCode 2232 - Minimize Result by Adding Parentheses to Expression

The problem presents a string expression in the form "<num1+<num2", where both <num1 and <num2 are positive integers represented as strings.

leetcodemediumstringenumeration
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
LeetCode 3173 - Bitwise OR of Adjacent Elements

The problem gives us an integer array nums of length n. We must create and return a new array called answer of length n - 1.

leetcodeeasyarraybit-manipulation
LeetCode 2589 - Minimum Time to Complete All Tasks

This problem is asking us to determine the minimum amount of time that a computer must be turned on to execute a set of tasks, given that each task has a specified time window [starti, endi] and requires a total duration durationi that does not need to be continuous.

leetcodehardarraybinary-searchstackgreedysorting
CF 148B - Escape

We are asked to simulate a pursuit scenario between a princess and a dragon. The princess runs at a constant speed, and the dragon flies faster but only begins chasing after a delay. Each time the dragon catches up, the princess can drop a bijou to distract him.

codeforcescompetitive-programmingimplementationmath
LeetCode 2727 - Is Object Empty

This problem asks us to determine if a given object or array is empty. In JavaScript terms, an object is empty if it has no key-value pairs, while an array is empty if it has no elements.

leetcodeeasy
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
CF 305A - Strange Addition

We are asked to select the largest possible subset of integers from a given set such that any two numbers in the subset can be summed by Vasya. Vasya’s summing rule is unusual: for each decimal place, at least one of the two numbers must have a zero in that place.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementation
LeetCode 2646 - Minimize the Total Price of the Trips

The problem gives us an undirected tree with n nodes. Every node has a price associated with it, and we are also given several trips between pairs of nodes. Since the graph is a tree, there is exactly one simple path between any two nodes.

leetcodehardarraydynamic-programmingtreedepth-first-searchgraph-theory
LeetCode 2070 - Most Beautiful Item for Each Query

The problem gives us a list of items, where each item has two properties: - price - beauty Each entry looks like: We are also given a list of queries.

leetcodemediumarraybinary-searchsorting
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 2393 - Count Strictly Increasing Subarrays

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

leetcodemediumarraymathdynamic-programming
LeetCode 1898 - Maximum Number of Removable Characters

The problem gives us two strings, s and p, and a list of indices removable. The string p is guaranteed to be a subsequence of s, meaning all characters in p appear in s in the same order, though not necessarily consecutively.

leetcodemediumarraytwo-pointersstringbinary-search
CF 146A - Lucky Ticket

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

codeforcescompetitive-programmingimplementation
LeetCode 2362 - Generate the Invoice

This is a SQL database problem involving two tables: | productid | price | | --- | --- | | Unique product identifier | Unit price of the product | | invoiceid | productid | quantity | | --- | --- | --- | | Invoice identifier | Product purchased | Number of units purchased |…

leetcodeharddatabase
CF 212E - IT Restaurants

We are asked to place two types of restaurants on a tree-shaped city map in such a way that no two adjacent junctions host different types, each junction hosts at most one restaurant, and each network has at least one restaurant.

codeforcescompetitive-programmingdfs-and-similardptrees
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 2946 - Matrix Similarity After Cyclic Shifts

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

leetcodeeasyarraymathmatrixsimulation
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
CF 424B - Megacity

Codeforces 424B: Megacity

codeforcescompetitive-programmingbinary-searchgreedyimplementationsortings
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 2250 - Count Number of Rectangles Containing Each Point

Here is the complete, detailed technical solution guide for LeetCode 2250 - Count Number of Rectangles Containing Each Point in a single, comprehensive response. The problem provides two arrays: rectangles and points.

leetcodemediumarrayhash-tablebinary-searchbinary-indexed-treesorting
CF 263C - Circle of Numbers

We are given a hidden cyclic arrangement of the integers from 1 to n placed around a circle. From this arrangement, someone constructed a set of ordered pairs describing connections between values.

codeforcescompetitive-programmingbrute-forcedfs-and-similarimplementation
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
LeetCode 2716 - Minimize String Length

The problem asks us to minimize the length of a given string s by repeatedly performing two types of deletion operations. In the first operation, we can pick a character at some index and delete the closest identical character to its left if one exists.

leetcodeeasyhash-tablestring
CF 182A - Battlefield

We are asked to simulate movement across a 2D plane from a starting point $A$ to a destination $B$ while avoiding a periodic laser. The laser alternates between charging and firing, with durations $a$ and $b$ seconds, respectively.

codeforcescompetitive-programminggeometrygraphsimplementationshortest-paths
LeetCode 2449 - Minimum Number of Operations to Make Arrays Similar

We are given two arrays, nums and target, of equal length. In a single operation, we choose two different indices and add 2 to one element while subtracting 2 from another element.

leetcodehardarraygreedysorting
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 414B - Mashmokh and ACM

We are asked to count how many sequences of fixed length we can build from integers between 1 and n, with two constraints. First, the sequence is non-decreasing. Second, every element must divide the next one in the sequence.

codeforcescompetitive-programmingcombinatoricsdpnumber-theory