brain

tamnd's digital brain — notes, problems, research

42630 notes

CF 414D - Mashmokh and Water Tanks

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

codeforcescompetitive-programmingbinary-searchdata-structuresgreedytreestwo-pointers
CF 424C - Magic Formulas

Codeforces 424C: Magic Formulas

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

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

leetcodeeasyarraytwo-pointersstring
LeetCode 2971 - Find Polygon With the Largest Perimeter

The problem gives us an array nums containing positive integers. Each integer represents a potential side length that we may use when constructing a polygon. A polygon must have at least three sides.

leetcodemediumarraygreedysortingprefix-sum
LeetCode 2181 - Merge Nodes in Between Zeros

The problem gives us a singly linked list where the values are grouped between 0 nodes. The list always starts with 0 and ends with 0, and there are no two consecutive zeros. Every sequence of non-zero nodes between two zeros represents one group.

leetcodemediumlinked-listsimulation
CF 236B - Easy Number Challenge

We need to compute the sum of the number of divisors of every product i j k, where i ranges from 1 to a, j ranges from 1 to b, and k ranges from 1 to c. For each triple (i, j, k), we evaluate d(i j k), where d(x) means the number of positive divisors of x.

codeforcescompetitive-programmingimplementationnumber-theory
LeetCode 2302 - Count Subarrays With Score Less Than K

The problem asks us to count the number of contiguous subarrays of a given array nums whose score is strictly less than a given threshold k. The score of a subarray is defined as the product of its sum and its length.

leetcodehardarraybinary-searchsliding-windowprefix-sum
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
CF 303B - Rectangle Puzzle II

We have a grid-aligned rectangle of size n × m. Every valid point has integer coordinates between (0, 0) and (n, m). We must choose another axis-aligned rectangle inside it. The rectangle is described by four integers (x1, y1, x2, y2).

codeforcescompetitive-programmingimplementationmath
LeetCode 1889 - Minimum Space Wasted From Packaging

The problem gives us a list of package sizes and several suppliers. Each supplier offers an unlimited number of boxes, but only in certain fixed sizes. We must choose exactly one supplier and pack every package using only the box sizes that supplier provides.

leetcodehardarraybinary-searchsortingprefix-sum
CF 253E - Printer

We are simulating a single-threaded printer that receives tasks over time. Each task arrives at a given time, has a known number of pages, and a priority that determines the order in which it is served when multiple tasks are waiting.

codeforcescompetitive-programmingbinary-searchdata-structuresimplementationsortings
LeetCode 2587 - Rearrange Array to Maximize Prefix Score

The problem gives us a 0-indexed array of integers, nums, which can include negative numbers, zero, and positive numbers. We are allowed to reorder the elements in any way we choose.

leetcodemediumarraygreedysortingprefix-sum
LeetCode 2882 - Drop Duplicate Rows

The problem asks us to process a DataFrame representing customers and remove rows that have duplicate email addresses. Specifically, if multiple rows share the same email value, only the first occurrence should be kept, and all subsequent duplicates should be discarded.

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

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

leetcodemediumstringrolling-hashstring-matchinghash-function
LeetCode 2502 - Design Memory Allocator

The problem requires designing a memory allocator that manages a fixed-size memory array. Initially, all memory units are free, and the allocator supports two operations: allocating a block of consecutive free memory units for a given ID (mID) and freeing all memory units…

leetcodemediumarrayhash-tabledesignsimulation
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
CF 252A - Little Xor

We are given a sequence of non-negative integers and we want to pick a contiguous block of elements such that when we take the bitwise XOR of everything inside that block, the result is as large as possible.

codeforcescompetitive-programmingbrute-forceimplementation
LeetCode 2761 - Prime Pairs With Target Sum

The problem asks us to find all pairs of prime numbers (x, y) such that both numbers are between 1 and n inclusive, their sum equals n, and x <= y.

leetcodemediumarraymathenumerationnumber-theory
LeetCode 3024 - Type of Triangle

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

leetcodeeasyarraymathsorting
CF 144D - Missile Silos

We are given a connected weighted undirected graph representing cities and roads. City s is the capital. A missile silo may be located either exactly on a city or at some interior point of a road. A position is valid if its shortest-path distance to the capital is exactly l.

codeforcescompetitive-programmingdata-structuresdfs-and-similargraphsshortest-paths
CF 246A - Buggy Sorting

We are given only a single integer $n$, and we must construct an array of length $n$ that either breaks a very specific sorting procedure or prove that no such array exists.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortings
LeetCode 3261 - Count Substrings That Satisfy K-Constraint II

We are given a binary string s, an integer k, and many range queries. For each query [l, r], we only consider the substring s[l..r]. Among all substrings completely contained inside this range, we must count how many satisfy the k-constraint.

leetcodehardarraystringbinary-searchsliding-windowprefix-sum
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
CF 245F - Log Stream Analysis

We are given a chronologically ordered stream of log entries, where each entry has an exact timestamp down to the second and an associated message describing a program warning.

codeforcescompetitive-programmingbinary-searchbrute-forceimplementationstrings
LeetCode 2257 - Count Unguarded Cells in the Grid

This problem gives us an m x n grid containing three types of cells: 1. Guard cells 2. Wall cells 3. Empty cells Each guard can observe cells in the four cardinal directions: - Up - Down - Left - Right A guard continues seeing cells in a direction until the view is blocked by…

leetcodemediumarraymatrixsimulation
LeetCode 3133 - Minimum Array End

The problem asks us to construct a strictly increasing array nums of length n such that the bitwise AND of all elements equals x. Among all valid arrays, we want to minimize the last element, nums[n - 1]. The constraints are important: - Every element must be a positive integer.

leetcodemediumbit-manipulation
LeetCode 2327 - Number of People Aware of a Secret

The problem describes how a secret spreads over time. On day 1, exactly one person knows the secret. Every person who learns the secret behaves according to two rules: 1. They must wait delay days before they can begin sharing the secret. 2.

leetcodemediumdynamic-programmingqueuesimulation
LeetCode 2935 - Maximum Strong Pair XOR II

The problem asks us to find the maximum XOR value of a strong pair in a given array of integers nums. A pair (x, y) is considered strong if it satisfies the condition |x - y| <= min(x, y).

leetcodehardarrayhash-tablebit-manipulationtriesliding-window
LeetCode 3296 - Minimum Number of Seconds to Make Mountain Height Zero

The problem asks us to calculate the minimum amount of time required for a team of workers to reduce the height of a mountain to zero, given that each worker has a specific time cost for performing work and the total work time grows linearly for consecutive units of height.

leetcodemediumarraymathbinary-searchgreedyheap-(priority-queue)
LeetCode 3060 - User Activities within Time Bounds

The Sessions table stores information about user activity sessions on a platform. Each row represents a single session and contains: | Column | Meaning | | --- | --- | | userid | The user who performed the session | | sessionstart | When the session began | | sessionend | When…

leetcodeharddatabase
LeetCode 2371 - Minimize Maximum Value in a Grid

The problem presents a matrix grid of size m x n with distinct positive integers. The goal is to transform this matrix so that every element is replaced with another positive integer while maintaining the relative order in each row and column.

leetcodehardarrayunion-findgraph-theorytopological-sortsortingmatrix
LeetCode 3364 - Minimum Positive Sum Subarray

The problem asks us to find the smallest positive sum among all subarrays whose lengths fall within a given range [l, r]. A subarray is a contiguous section of the array. We are allowed to choose any non-empty contiguous segment as long as: 1.

leetcodeeasyarraysliding-windowprefix-sum
LeetCode 3217 - Delete Nodes From Linked List Present in Array

This problem asks us to modify a singly linked list by removing all nodes whose values appear in a given array nums. The input consists of two elements: an array of integers nums and the head of a linked list.

leetcodemediumarrayhash-tablelinked-list
LeetCode 2945 - Find Maximum Non-decreasing Array Length

This problem asks us to determine the maximum length of a non-decreasing array that can be obtained from a given integer array nums by performing a sequence of subarray sum operations.

leetcodehardarraybinary-searchdynamic-programmingstackqueuemonotonic-stackmonotonic-queue
CF 417E - Square Table

We are asked to fill an $n times m$ grid with positive integers not exceeding $10^8$. The constraint is not about individual cells but about structure: for every row and every column, if we square all numbers in that line and sum them, the result must itself be a perfect square.

codeforcescompetitive-programmingconstructive-algorithmsmathprobabilities
LeetCode 1930 - Unique Length-3 Palindromic Subsequences

The problem asks us to count unique palindromic subsequences of length 3 in a given string s. A palindromic string reads the same forwards and backwards, and in this case, we only care about strings of exactly three characters.

leetcodemediumhash-tablestringbit-manipulationprefix-sum
LeetCode 3241 - Time Taken to Mark All Nodes

We are given an undirected tree with n nodes. A tree is a connected graph with exactly n - 1 edges and no cycles. Each node has a special propagation delay determined entirely by its parity: - Odd-numbered nodes become marked 1 time unit after one of their neighbors is marked.

leetcodeharddynamic-programmingtreedepth-first-searchgraph-theory
CF 177A1 - Good Matrix Elements

We are given a square matrix of size n × n, where n is guaranteed to be an odd number. Each element of the matrix is a non-negative integer.

codeforcescompetitive-programmingimplementation
LeetCode 3008 - Find Beautiful Indices in the Given Array II

This problem asks us to find every starting index where the substring a appears inside the string s, subject to an additional proximity condition involving another substring b. More specifically, an index i is considered beautiful if two conditions hold: 1.

leetcodehardtwo-pointersstringbinary-searchrolling-hashstring-matchinghash-function
LeetCode 2289 - Steps to Make Array Non-decreasing

The problem asks us to determine how many steps it takes to make a given array nums non-decreasing by repeatedly removing elements that break the non-decreasing property. Specifically, for each step, any element nums[i] where nums[i - 1] nums[i] is removed.

leetcodemediumarraylinked-listdynamic-programmingstackmonotonic-stacksimulation
LeetCode 3137 - Minimum Number of Operations to Make Word K-Periodic

The problem asks us to transform a given string word of length n into a k-periodic string using the minimum number of operations. A string is k-periodic if it can be formed by repeating a substring s of length k multiple times.

leetcodemediumhash-tablestringcounting
LeetCode 2612 - Minimum Reverse Operations

This will be a very large, multi-thousand-word technical guide because of the required depth, full proofs, worked examples, Python and Go implementations, detailed walkthroughs, complexity reasoning, and exhaustive tests.

leetcodehardarrayhash-tablebreadth-first-searchunion-findordered-set
LeetCode 1910 - Remove All Occurrences of a Substring

The problem asks us to repeatedly remove occurrences of a substring part from a string s. The important detail is that on every operation, we must remove the leftmost occurrence of part. We continue performing removals until part no longer appears anywhere inside s.

leetcodemediumstringstacksimulation
LeetCode 3076 - Shortest Uncommon Substring in an Array

The problem asks us to find, for each string in a given array, the shortest substring that does not appear in any other string in the array. If multiple shortest substrings exist, we must choose the lexicographically smallest one.

leetcodemediumarrayhash-tablestringtrie
LeetCode 2620 - Counter

The problem is asking us to implement a simple counter function with a closure-like behavior. Given an integer n, we need to return a function counter() that, when called the first time, returns n, and then increments the returned value by one for every subsequent call.

leetcodeeasy
CF 420B - Online Meeting

We have a meeting log for a team of developers where each log entry records either a user logging in or logging out. The log may start or end in the middle of the meeting, so we do not know who was online before the first recorded message.

codeforcescompetitive-programmingimplementation
CF 301B - Yaroslav and Time

We are given a set of stations placed on a 2D grid. Moving between any two stations takes time proportional to their Manhattan distance multiplied by a constant factor $d$.

codeforcescompetitive-programmingbinary-searchgraphsshortest-paths
LeetCode 3030 - Find the Grid of Region Average

The problem gives us a grayscale image represented as an m x n matrix called image. Every value in the matrix is an integer between 0 and 255, representing the intensity of a pixel. We must examine every possible 3 x 3 subgrid inside the image.

leetcodemediumarraymatrix
LeetCode 2941 - Maximum GCD-Sum of a Subarray

The problem asks us to find the maximum gcd-sum of a subarray of a given integer array nums with the constraint that the subarray has at least k elements.

leetcodehardarraymathbinary-searchnumber-theory
LeetCode 2440 - Create Components With Same Value

This problem is asking us to take an undirected tree where each node has a numerical value and determine how many edges we can remove such that every resulting connected component has the same total value.

leetcodehardarraymathtreedepth-first-searchenumeration
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 2311 - Longest Binary Subsequence Less Than or Equal to K

The problem asks us to find the length of the longest subsequence of a given binary string s such that the resulting binary number is less than or equal to a given integer k. A subsequence is any selection of characters from s in their original order, possibly skipping some.

leetcodemediumstringdynamic-programminggreedymemoization
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
LeetCode 2591 - Distribute Money to Maximum Children

Problem Understanding

leetcodeeasymathgreedy
LeetCode 2647 - Color the Triangle Red

The problem asks us to determine the minimal set of initial triangles to color red in an equilateral triangle of side length n, such that by repeatedly applying a propagation rule, all triangles eventually become red.

leetcodehardarraymath
LeetCode 2515 - Shortest Distance to Target String in a Circular Array

The problem asks us to find the shortest distance from a given starting index in a circular array of strings to a target string.

leetcodeeasyarraystring
LeetCode 2045 - Second Minimum Time to Reach Destination

Here is a comprehensive technical solution guide for LeetCode 2045 following your requested format: The problem asks us to find the second minimum time to travel from vertex 1 to vertex n in a weighted, undirected graph, where the weight of every edge is the same (time).

leetcodehardbreadth-first-searchgraph-theoryshortest-path
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 2153 - The Number of Passengers in Each Bus II

The problem describes a simulation of passengers arriving at a bus station and buses arriving to pick them up. Each bus has a unique ID, an arrival time, and a limited capacity. Each passenger has a unique ID and an arrival time.

leetcodeharddatabase
LeetCode 3289 - The Two Sneaky Numbers of Digitville

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

leetcodeeasyarrayhash-tablemath
CF 162B - Binary notation

We are given a single positive integer and must print its representation in base 2. In other words, instead of expressing the number as powers of 10, we express it as powers of 2 using only digits 0 and 1.

codeforcescompetitive-programming*special
LeetCode 3035 - Maximum Palindromes After Operations

This problem gives us an array of strings, words, and allows us to swap any character with any other character across the entire collection of strings. The swaps are completely unrestricted.

leetcodemediumarrayhash-tablestringgreedysortingcounting
LeetCode 2756 - Query Batching

The problem asks us to design a throttled batching system for asynchronous queries. Instead of immediately sending every incoming request individually, we want to intelligently combine multiple requests together whenever possible.

leetcodehard
LeetCode 2058 - Find the Minimum and Maximum Number of Nodes Between Critical Points

The problem gives us a singly linked list and asks us to identify all of its critical points. A critical point is a node that is either a local maximum or a local minimum.

leetcodemediumlinked-list
LeetCode 2095 - Delete the Middle Node of a Linked List

The problem gives us the head of a singly linked list and asks us to delete the middle node. The definition of the middle node is based on 0-based indexing. If the list has n nodes, then the middle node is the node at index ⌊n / 2⌋.

leetcodemediumlinked-listtwo-pointers
LeetCode 2636 - Promise Pool

This problem asks us to implement a concurrency limiter for asynchronous operations. We are given an array called functions, where each element is itself a function. When one of these functions is called, it returns a Promise.

leetcodemedium
LeetCode 2867 - Count Valid Paths in a Tree

That is a long, structured reference document with multiple required sections, detailed prose, two full implementations, worked examples, test cases, and edge-case analysis. To keep quality high and avoid truncation, I will provide it in a complete guide format.

leetcodehardmathdynamic-programmingtreedepth-first-searchnumber-theory
LeetCode 2150 - Find All Lonely Numbers in the Array

The corridor is represented as a string where each character is either 'S' for a seat or 'P' for a plant. We already have fixed dividers at both ends of the corridor, and we may optionally place additional dividers between adjacent positions.

leetcodemediumarrayhash-tablecounting
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
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 2477 - Minimum Fuel Cost to Report to the Capital

The problem gives us a country road network that forms a tree. A tree is a connected graph with no cycles, which means there is exactly one path between any two cities. The cities are numbered from 0 to n - 1, and city 0 is always the capital.

leetcodemediumtreedepth-first-searchbreadth-first-searchgraph-theory
LeetCode 2737 - Find the Closest Marked Node

That is a very large, detailed reference document with multiple long sections, full walkthroughs, two language implementations, worked examples, test suites, and edge case analysis for LeetCode 2737.

leetcodemediumarraygraph-theoryheap-(priority-queue)shortest-path
LeetCode 2489 - Number of Substrings With Fixed Ratio

The problem gives us a binary string s, along with two coprime integers num1 and num2. We need to count how many non-empty substrings contain 0s and 1s in the exact ratio num1 : num2.

leetcodemediumhash-tablemathstringprefix-sum
LeetCode 3018 - Maximum Number of Removal Queries That Can Be Processed I

The problem asks us to process a sequence of removal queries on an array nums, with an optional initial operation where we can replace nums with any subsequence of itself to optimize query processing. Each query specifies a threshold value.

leetcodehardarraydynamic-programming
LeetCode 2569 - Handling Sum Queries After Update

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

leetcodehardarraysegment-tree
LeetCode 2828 - Check if a String Is an Acronym of Words

This problem asks us to determine whether a given string s is exactly the acronym formed from an array of words. An acronym is created by taking the first character from each word in the words array and concatenating those characters in the same order as the words appear.

leetcodeeasyarraystring
LeetCode 3157 - Find the Level of Tree with Minimum Sum

The problem gives us the root of a binary tree, where every node contains a positive integer value. Our task is to determine which level of the tree has the smallest sum of node values.

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 1925 - Count Square Sum Triples

This problem asks us to count all ordered triples (a, b, c) such that: - 1 <= a, b, c <= n - a² + b² = c² This is the classic Pythagorean theorem relationship. Any triple satisfying this condition is called a square triple in the problem statement.

leetcodeeasymathenumeration
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 1985 - Find the Kth Largest Integer in the Array

This problem asks us to find the kth largest value among a list of integers that are represented as strings. Each element in nums is a non-negative integer encoded as a string with no leading zeros, and we are required to return the kth largest value according to numeric order…

leetcodemediumarraystringdivide-and-conquersortingheap-(priority-queue)quickselect
CF 431E - Chemistry Experiment

We are given a set of containers, each containing some fixed amount of mercury. Over time, two kinds of operations happen. The first operation changes the mercury amount in a single container.

codeforcescompetitive-programmingbinary-searchdata-structuresternary-search
CF 209A - Multicolored Marbles

Polycarpus has a row of n marbles, each either red or blue, and he wants to count how many subsequences of these marbles form a zebroid, which is a sequence where the colors strictly alternate. A zebroid can be as short as one marble.

codeforcescompetitive-programmingdpmath
CF 241G - Challenging Balloons

We have a row of balloons placed at increasing positions on a line. Each balloon has a pressure endurance, which limits how large its radius can grow. We inflate balloons sequentially from left to right.

codeforcescompetitive-programmingconstructive-algorithms
LeetCode 2653 - Sliding Subarray Beauty

The problem asks us to compute the beauty of every contiguous subarray of size k within a given integer array nums. The beauty of a subarray is defined as the xth smallest negative number in that subarray. If a subarray contains fewer than x negative numbers, the beauty is 0.

leetcodemediumarrayhash-tablesliding-window
LeetCode 2427 - Number of Common Factors

The problem gives us two positive integers, a and b, and asks us to count how many integers divide both numbers evenly. A number x is considered a common factor if: - a % x == 0 - b % x == 0 This means x divides both integers without leaving a remainder.

leetcodeeasymathenumerationnumber-theory
LeetCode 3154 - Find Number of Ways to Reach the K-th Stair

Let's dive into a comprehensive solution guide for LeetCode 3154 - Find Number of Ways to Reach the K-th Stair. This problem involves Alice navigating a staircase starting at stair 1, aiming to reach stair k.

leetcodehardmathdynamic-programmingbit-manipulationmemoizationcombinatorics
CF 270A - Fancy Fence

We are asked to determine whether a robot, which can only make fence corners at a fixed angle a, can construct a regular polygon. A regular polygon is defined as a closed shape with all sides and all angles equal.

codeforcescompetitive-programminggeometryimplementationmath
LeetCode 3214 - Year on Year Growth Rate

This problem asks us to compute the year-on-year, often abbreviated as YoY, growth rate of total spending for every product in the usertransactions table. Each row in the input table represents a single transaction.

leetcodeharddatabase
LeetCode 3012 - Minimize Length of Array Using Operations

The problem gives us a 0-indexed array of positive integers and asks us to repeatedly perform a specific operation to reduce the array's length as much as possible.

leetcodemediumarraymathgreedynumber-theory
CF 201B - Guess That Car!

The problem places us in a grid-like parking lot of size 4·n by 4·m meters, divided into squares of 4 by 4 meters, each containing a car with a known "rarity" value.

codeforcescompetitive-programmingmathternary-search
LeetCode 3051 - Find Candidates for Data Scientist Position

You included two different LeetCode problems with conflicting templates. The second problem appears to be the one you want covered: LeetCode 3051 - Find Candidates for Data Scientist Position (Database) However, the required sections still reference Python and Go solutions…

leetcodeeasydatabase
CF 194B - Square

We have a person walking around the border of a square whose side length is n. He starts at the lower-left corner and places a cross there immediately. After that, he keeps moving clockwise along the perimeter, placing another cross every n + 1 meters.

codeforcescompetitive-programmingmath
LeetCode 2492 - Minimum Score of a Path Between Two Cities

The problem asks us to find the minimum possible score of a path between city 1 and city n in a graph defined by n cities and roads. Each road connects two cities bidirectionally and has an associated distance.

leetcodemediumdepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 2339 - All the Matches of the League

The Teams table contains the names of all teams participating in a league. Each row represents exactly one team, and the teamname column is guaranteed to contain unique values.

leetcodeeasydatabase
CF 243B - Hydra

We are given an undirected simple graph and two small integers $h$ and $t$. We are asked to determine whether inside this graph there exists a very specific structure consisting of two special vertices connected by an edge.

codeforcescompetitive-programminggraphssortings
CF 152D - Frames

We are given an n × m grid where some cells are painted with and the others are empty .. The picture is supposed to come from painting exactly two rectangular frames. A frame is not a filled rectangle. Only the border cells of the rectangle are painted.

codeforcescompetitive-programmingbrute-force
CF 301C - Yaroslav and Algorithm

We must construct a small string rewriting program. The program consists of ordered commands. Each command searches for a substring and replaces its first occurrence with another string. Some commands continue execution after replacement, while others terminate immediately.

codeforcescompetitive-programmingconstructive-algorithms
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 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
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