brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 441D - Valera and Swaps

We are given a permutation, which we can think of as a row of numbered positions, where each position contains a distinct value from 1 to n. A swap operation exchanges two positions, and after a sequence of swaps we obtain another permutation.

codeforcescompetitive-programmingconstructive-algorithmsdsugraphsimplementationmathstring-suffix-structures
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 2842 - Count K-Subsequences of a String With Maximum Beauty

The problem requires us to count k-subsequences of a string s that have the maximum beauty, where beauty is defined as the sum of the frequency of each character in the subsequence. A k-subsequence is a subsequence of length k where all characters are unique.

leetcodehardhash-tablemathstringgreedysortingcombinatorics
LeetCode 2601 - Prime Subtraction Operation

The problem gives us an integer array nums and asks whether it is possible to transform the array into a strictly increasing sequence by performing a special operation.

leetcodemediumarraymathbinary-searchgreedynumber-theory
LeetCode 3329 - Count Substrings With K-Frequency Characters II

The problem asks us to count how many substrings of a given string s contain at least one character that appears at least k times within that substring. A substring is a contiguous portion of the string.

leetcodehardhash-tablestringsliding-window
CF 140B - New Year Cards

Alexander receives cards from friends one by one. Friend i sends card i, so card numbers and friend numbers are the same thing. At any moment Alexander may decide to send cards to some friends. He never creates new cards, he only reuses cards he has already received.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 150D - Mission Impassable

We start with a string of length l. In one move we may choose any contiguous substring that is a palindrome and whose length k is allowed, meaning a[k] != -1. After deleting it, the remaining characters concatenate together. The score gained from this move is a[k].

codeforcescompetitive-programmingdpstrings
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 2091 - Removing Minimum and Maximum From Array

The problem gives us a 0-indexed array of distinct integers. Among these integers, exactly one value is the smallest element in the array, and exactly one value is the largest element in the array. The task is to remove both of these elements using the fewest deletions possible.

leetcodemediumarraygreedy
CF 301E - Yaroslav and Arrangements

We are given three integers. The length of the array cannot exceed n, every value must lie between 1 and m, and the number of distinct cyclic arrangements that satisfy a special adjacency rule must be between 1 and k. The adjacency rule defines a "good" array.

codeforcescompetitive-programmingdp
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 241E - Flights

We are given a directed acyclic graph of cities and one-way flights. Every flight initially takes 1 hour. We may independently change any flight duration to either 1 or 2 hours.

codeforcescompetitive-programminggraphsshortest-paths
LeetCode 2483 - Minimum Penalty for a Shop

The problem asks us to determine the optimal hour to close a shop to minimize a penalty based on customer arrivals. The input is a string customers where each character represents an hour: 'Y' means customers arrive, and 'N' means no customers arrive.

leetcodemediumstringprefix-sum
CF 145B - Lucky Number 2

We need to construct the lexicographically smallest lucky number consisting only of digits 4 and 7 such that four substring counts match given values.

codeforcescompetitive-programmingconstructive-algorithms
LeetCode 3009 - Maximum Number of Intersections on the Chart

I can provide the full guide, but I want to avoid giving you a technically incorrect reference document. For LeetCode 3009, there are two subtly different interpretations that materially change the optimal algorithm and correctness proof: - whether intersections at a chart…

leetcodehardarrayhash-tablemathbinary-indexed-treegeometrysweep-linesorting
LeetCode 1990 - Count the Number of Experiments

This problem gives us a database table named Experiments. Each row represents a single experiment performed by a participant. Every experiment belongs to one platform and one experiment category.

leetcodemediumdatabase
LeetCode 2030 - Smallest K-Length Subsequence With Occurrences of a Letter

The problem asks us to construct the lexicographically smallest subsequence of length k from the string s, while ensuring that a specific character, letter, appears at least repetition times in the resulting subsequence.

leetcodehardstringstackgreedymonotonic-stack
LeetCode 2618 - Check if Object Instance of Class

The problem asks us to implement a function that checks whether a given value is an instance of a specified class or any of its superclasses.

leetcodemedium
LeetCode 3295 - Report Spam Message

This problem asks us to determine whether a given message should be classified as spam. We are given two arrays of strings: - message, which contains the words appearing in the message. - bannedWords, which contains words that are considered banned.

leetcodemediumarrayhash-tablestring
LeetCode 3171 - Find Subarray With Bitwise OR Closest to K

The problem asks us to find a subarray within a given array nums such that the absolute difference between the integer k and the bitwise OR of the subarray elements is minimized.

leetcodehardarraybinary-searchbit-manipulationsegment-tree
CF 242D - Dispute

We are given a graph of counters, where each counter starts at zero and is connected by undirected wires. Pressing a button on a counter increases its own value by one, and also increases the value of every directly connected neighbor by one.

codeforcescompetitive-programmingdfs-and-similargraphsgreedy
LeetCode 2880 - Select Data

This problem provides a pandas DataFrame named students with three columns: | Column | Description | | --- | --- | | studentid | Unique identifier for a student | | name | Student name | | age | Student age | The task is to return only the name and age columns for the student…

leetcodeeasy
CF 416E - President's Path

We are given a graph with n cities connected by m bidirectional roads, each with a positive length. The goal is to determine, for every pair of cities (s, t) with s < t, how many roads can appear on at least one shortest path from s to t.

codeforcescompetitive-programmingdpgraphsshortest-paths
CF 243A - The Brand New Function

We are given a sequence of non-negative integers. For any contiguous subarray of this sequence, we can compute its bitwise OR. The problem asks for the number of distinct values obtained from all such subarrays.

codeforcescompetitive-programmingbitmasks
LeetCode 2418 - Sort the People

This problem gives us two arrays of equal length: - names[i] represents the name of a person - heights[i] represents the height of that same person The two arrays are aligned by index, meaning the person at index i has both the name names[i] and the height heights[i].

leetcodeeasyarrayhash-tablestringsorting
LeetCode 2578 - Split With Minimum Sum

The problem asks us to take a positive integer num and split its digits into two non-negative integers num1 and num2 such that the sum num1 + num2 is minimized.

leetcodeeasymathgreedysorting
CF 261E - Maxim and Calculator

We are given a very small computational system that starts from two registers: the first register begins at 1 and the second at 0. From this starting point we can repeatedly apply two operations. One operation increments the second register by 1.

codeforcescompetitive-programmingbrute-forcedptwo-pointers
LeetCode 3392 - Count Subarrays of Length Three With a Condition

The problem gives us an integer array nums and asks us to count how many contiguous subarrays of length exactly 3 satisfy a specific mathematical condition.

leetcodeeasyarray
CF 444D - DZY Loves Strings

We are given a long string s and a list of pairs of small strings (ai, bi). For each pair, we need to find the shortest substring of s that contains both ai and bi as substrings. If no substring contains both, we report -1.

codeforcescompetitive-programmingbinary-searchhashingstringstwo-pointers
CF 251B - Playing with Permutations

Codeforces 251B: Playing with Permutations

codeforcescompetitive-programmingimplementationmath
LeetCode 2102 - Sequentially Ordinal Rank Tracker

The problem asks us to design a data structure that continuously tracks scenic locations ranked by two rules: 1. A higher score means a better location. 2. If two locations have the same score, the lexicographically smaller name is considered better.

leetcodeharddesignheap-(priority-queue)data-streamordered-set
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
LeetCode 2533 - Number of Good Binary Strings

The problem asks us to count how many binary strings satisfy a very specific structural rule. We are given four integers: - minLength, the minimum allowed length of a valid string - maxLength, the maximum allowed length of a valid string - oneGroup, the required divisibility…

leetcodemediumdynamic-programming
LeetCode 2152 - Minimum Number of Lines to Cover Points

This problem asks us to determine the minimum number of straight lines needed to cover a given set of points on an X-Y plane. Each point is defined by its (x, y) coordinates, and a straight line can pass through any number of points as long as they are collinear.

leetcodemediumarrayhash-tablemathdynamic-programmingbacktrackingbit-manipulationgeometrybitmask
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 3162 - Find the Number of Good Pairs I

The problem gives us two integer arrays, nums1 and nums2, along with a positive integer k. We need to count how many index pairs (i, j) satisfy the following condition: In mathematical terms, a pair is considered good if: The task is not asking us to return the pairs themselves.

leetcodeeasyarrayhash-table
LeetCode 2799 - Count Complete Subarrays in an Array

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

leetcodemediumarrayhash-tablesliding-window
LeetCode 1933 - Check if String Is Decomposable Into Value-Equal Substrings

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

leetcodeeasystring
CF 149B - Martian Clock

We are given a string representing a Martian time in the format "a:b", where a is the hour component and b is the minute component. Unlike Earth time in base 10, these strings could represent numbers in any numeral system with a base greater than 1.

codeforcescompetitive-programmingimplementation
LeetCode 2207 - Maximize Number of Subsequences in a String

This problem asks us to maximize the number of times a two-character string pattern occurs as a subsequence in a given string text, after inserting exactly one character.

leetcodemediumstringgreedyprefix-sum
LeetCode 2753 - Count Houses in a Circular Street II

The problem presents a circular street where each house has a door that can be either open or closed. You start at an arbitrary house and can perform three actions: check if the door is open, close the door, or move to the next house in the circular street.

leetcodehard
LeetCode 1891 - Cutting Ribbons

The problem requires determining the maximum possible length x of ribbons such that, after cutting or keeping the given ribbons in the array ribbons, you can obtain at least k ribbons of length x.

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 2155 - All Divisions With the Highest Score of a Binary Array

The problem gives us a binary array nums, meaning every element is either 0 or 1. We are allowed to divide the array at any index i where 0 <= i <= n, and that division creates two parts: - The left part contains elements from index 0 to i - 1 - The right part contains…

leetcodemediumarray
CF 161A - Dress'em in Vests!

We are tasked with equipping as many soldiers as possible with bulletproof vests. Each soldier has a preferred vest size, but they are willing to tolerate deviations within a given range. Specifically, the i-th soldier can wear any vest with a size between a[i] - x and a[i] + y.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedytwo-pointers
LeetCode 3088 - Make String Anti-palindrome

We are given a string s of even length, and we may swap any two characters any number of times. Since unrestricted swapping allows us to rearrange the string arbitrarily, the real task is to determine whether some permutation of the characters can form an anti-palindrome.

leetcodehardstringgreedysortingcounting-sort
LeetCode 2432 - The Employee That Worked on the Longest Task

The problem asks us to identify which employee worked the task with the longest duration given a sequence of tasks completed by employees. Each task is represented in logs[i] = [idi, leaveTimei], where idi is the employee id and leaveTimei is the time the task was completed.

leetcodeeasyarray
LeetCode 1895 - Largest Magic Square

The problem asks us to find the largest magic square inside a given m x n grid. A magic square is a k x k subgrid where the sum of each row, the sum of each column, and the sums of the two main diagonals are all equal.

leetcodemediumarraymatrixprefix-sum
CF 213D - Stars

We must construct n pentagram-shaped stars in the plane. Each star comes from a regular pentagon with side length 10, and the painted segments are exactly its five diagonals. The output is not just geometry. We also need a valid drawing order.

codeforcescompetitive-programmingconstructive-algorithmsgeometry
CF 229D - Towers

We are given a sequence of towers standing in a straight line, where the height of the tower at position i is h[i]. The goal is to make the sequence non-decreasing from left to right using a set of allowed operations.

codeforcescompetitive-programmingdpgreedytwo-pointers
LeetCode 3361 - Shift Distance Between Two Strings

The problem gives us two strings, s and t, of equal length. We want to transform s into t character by character using cyclic alphabet shifts. For every character in s, we are allowed to repeatedly perform one of two operations: 1.

leetcodemediumarraystringprefix-sum
LeetCode 2821 - Delay the Resolution of Each Promise

The problem asks us to take an array of functions, each returning a promise, and a delay time ms. We are to return a new array of functions where invoking any function in this array returns a promise that behaves like the original promise but resolves or rejects only after an…

leetcodemedium
CF 141D - Take-off Ramps

We are moving on a one-dimensional track from position 0 to position L. Walking is simple, one meter costs exactly one second, and we may move in either direction as long as we never go below 0. A ramp gives a shortcut, but using it has a strict structure.

codeforcescompetitive-programminggraphsshortest-paths
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
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 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 2881 - Create a New Column

The problem is asking us to modify a given DataFrame named employees by adding a new column called bonus. Each value in the bonus column should be exactly double the corresponding value in the salary column.

leetcodeeasy
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 1912 - Design Movie Rental System

The problem requires designing a movie rental system for multiple shops, where each shop carries at most one copy of each movie.

leetcodehardarrayhash-tabledesignheap-(priority-queue)ordered-set
LeetCode 2089 - Find Target Indices After Sorting Array

The problem gives us an integer array nums and an integer target. We must sort the array in non-decreasing order and then return every index where the value equals target.

leetcodeeasyarraybinary-searchsorting
CF 159A - Friends or Not

We are given a chronological log of private messages between users in a social network. Each record contains the sender, the receiver, and the timestamp of the message. Two users become friends if one of them replies to the other's message quickly enough.

codeforcescompetitive-programming*specialgreedyimplementation
LeetCode 3297 - Count Substrings That Can Be Rearranged to Contain a String I

We are given two lowercase strings, word1 and word2. A substring of word1 is considered valid if its characters can be rearranged so that word2 becomes a prefix of the rearranged string. To understand what this means, suppose word2 = "abc".

leetcodemediumhash-tablestringsliding-window
LeetCode 2532 - Time to Cross a Bridge

The problem asks us to simulate a scenario in which k workers transport n boxes from a right-side warehouse to a left-side warehouse across a bridge.

leetcodehardarrayheap-(priority-queue)simulation
LeetCode 2694 - Event Emitter

This problem asks us to design a simplified event system similar to the one used in environments like Node.js or browser DOM events. The goal is to implement an EventEmitter class that supports two operations: 1. Subscribing callback functions to named events 2.

leetcodemedium
LeetCode 3073 - Maximum Increasing Triplet Value

We are given an integer array nums, and we must find three indices (i, j, k) such that: - i < j < k - nums[i] < nums[j] < nums[k] Among all valid increasing triplets, we want to maximize the expression: The task is not to maximize the sum of the triplet.

leetcodemediumarrayordered-set
LeetCode 2342 - Max Sum of a Pair With Equal Sum of Digits

The problem requires finding the maximum sum of a pair of numbers in an array such that the sum of the digits of both numbers is equal. Specifically, you are given a 0-indexed array nums containing positive integers. You can choose two distinct indices i and j such that i !

leetcodemediumarrayhash-tablesortingheap-(priority-queue)
LeetCode 2956 - Find Common Elements Between Two Arrays

This problem asks us to compare two integer arrays and count how many elements from one array appear in the other. More specifically, we need to compute two values: - answer1 is the number of indices i in nums1 such that nums1[i] appears at least once in nums2.

leetcodeeasyarrayhash-table
CF 238B - Boring Partition

We are given an array of integers and a value h. Every pair of elements contributes a value depending on whether the two elements are placed into the same group or different groups.

codeforcescompetitive-programmingconstructive-algorithms
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
LeetCode 1860 - Incremental Memory Leak

The problem models a faulty program that continuously consumes memory over time. There are two memory sticks, represented by the integers memory1 and memory2. At each second, the program allocates an increasing number of bits: - At second 1, it allocates 1 bit.

leetcodemediummathsimulation
LeetCode 2570 - Merge Two 2D Arrays by Summing Values

The problem gives us two sorted 2D integer arrays, nums1 and nums2, where every element is a pair of integers in the form [id, value]. Each id uniquely identifies an entry inside its own array, and the corresponding value represents that id's associated number.

leetcodeeasyarrayhash-tabletwo-pointers
CF 166D - Shoe Store

We have a collection of shoes, where every shoe has a unique size and a price. We also have customers, where each customer has a budget and a foot size. A customer can buy a shoe only if two conditions hold.

codeforcescompetitive-programmingdpgraph-matchingsgreedysortingstwo-pointers
LeetCode 2431 - Maximize Total Tastiness of Purchased Fruits

This problem asks us to maximize the total tastiness of fruits we purchase while staying within a fixed budget. Each fruit has two attributes: a price and a tastiness value. We may either skip a fruit or buy it, but each fruit can only be purchased once.

leetcodemediumarraydynamic-programming
LeetCode 3343 - Count Number of Balanced Permutations

We are given a string num consisting only of digits. We may rearrange the digits in any possible way, but we only count distinct permutations. A permutation is considered balanced if the sum of the digits placed at even indices equals the sum of the digits placed at odd indices.

leetcodehardmathstringdynamic-programmingcombinatorics
LeetCode 3185 - Count Pairs That Form a Complete Day II

The problem asks us to count pairs of elements in an integer array hours such that the sum of the two elements is a multiple of 24, which we call a "complete day." Each pair (i, j) must satisfy i < j.

leetcodemediumarrayhash-tablecounting
LeetCode 3265 - Count Almost Equal Pairs I

The problem asks us to find the number of index pairs (i, j) in an array nums such that i < j and the integers nums[i] and nums[j] are almost equal.

leetcodemediumarrayhash-tablesortingcountingenumeration
LeetCode 2850 - Minimum Moves to Spread Stones Over Grid

This problem asks us to take a 3x3 grid of integers representing stones in each cell and redistribute them so that every cell contains exactly one stone. Each move consists of moving a stone from one cell to a directly adjacent cell (sharing a side, not a diagonal).

leetcodemediumarraydynamic-programmingbacktrackingbit-manipulationmatrixbitmask
LeetCode 3195 - Find the Minimum Area to Cover All Ones I

The problem asks us to find the smallest rectangle that covers all the 1's in a given 2D binary grid. The grid consists of rows and columns where each cell is either 0 or 1.

leetcodemediumarraymatrix
CF 221A - Little Elephant and Function

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

codeforcescompetitive-programmingimplementationmath
LeetCode 2334 - Subarray With Elements Greater Than Varying Threshold

This problem asks us to find a contiguous subarray whose elements are all sufficiently large relative to the subarray length. More specifically, for a subarray of length k, every element inside that subarray must satisfy: We are allowed to return the size k of any valid subarray.

leetcodehardarraystackunion-findmonotonic-stack
LeetCode 3131 - Find the Integer Added to Array I

The problem gives us two integer arrays, nums1 and nums2, which have the same length. We are told that every element in nums1 was modified by adding the same integer x, and after this transformation the resulting array became equal to nums2.

leetcodeeasyarray
LeetCode 2534 - Time Taken to Cross the Door

This problem asks us to simulate how people pass through a single door over time while following a specific priority policy. Every person arrives at a certain second and wants to either enter or exit.

leetcodehardarrayqueuesimulation
LeetCode 2528 - Maximize the Minimum Powered City

The problem asks us to determine the maximum possible minimum power that any city can have after optimally adding k new power stations to an existing configuration.

leetcodehardarraybinary-searchgreedyqueuesliding-windowprefix-sum
LeetCode 2199 - Finding the Topic of Each Post

The problem gives us two database tables, Keywords and Posts. The Keywords table maps words to topic IDs. A single topic can have multiple words associated with it, and a single word may belong to multiple topics.

leetcodeharddatabase
LeetCode 2773 - Height of Special Binary Tree

This problem gives us the root of a special binary tree. At first glance, it looks like a normal binary tree, but there is an unusual property involving the leaf nodes.

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-tree
CF 160B - Unlucky Ticket

We are given a ticket represented as a string of 2n digits, where n is between 1 and 100. The first half of the ticket contains the first n digits and the second half contains the remaining n digits. We are asked to determine whether the ticket is “definitely unlucky.

codeforcescompetitive-programminggreedysortings
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 2082 - The Number of Rich Customers

The problem gives us a database table named Store. Each row in the table represents a single bill issued to a customer.

leetcodeeasydatabase
CF 354D - Transferring Pyramid

We are given a triangular pyramid structure made of cells arranged in rows. The first row has one cell, the second row has two, and so on, up to n rows. Each cell can hold a value.

codeforcescompetitive-programmingdp
CF 417A - Elimination

We are organizing a programming competition where the goal is to select at least $n cdot m$ finalists. Participants can qualify in three ways: first, by winning one of the main elimination rounds, which has $c$ problems and produces $n$ winners; second, by winning one of the…

codeforcescompetitive-programmingdpimplementationmath
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
LeetCode 2704 - To Be Or Not To Be

This problem asks us to implement a very small testing utility that mimics the behavior of assertion libraries used in real software development. We need to create a function named expect that accepts any value and returns an object containing two methods: toBe and notToBe.

leetcodeeasy
CF 238C - World Eater Brothers

We are given a world of n countries connected by n-1 directed roads. Ignoring the direction of these roads, the countries form a tree. Each brother wants to establish rule in some country and can control every country reachable via directed roads.

codeforcescompetitive-programmingdfs-and-similardpgreedytrees
CF 352A - Jeff and Digits

We are given a multiset of cards, each card showing either the digit 0 or the digit 5. From these cards we may choose any subset and arrange the chosen digits into a number written in a single line. Our goal is to build the largest possible number that is divisible by 90.

codeforcescompetitive-programmingbrute-forceimplementationmath
LeetCode 2106 - Maximum Fruits Harvested After at Most K Steps

In this problem, we are given several fruit piles placed on an infinite one dimensional number line. Each pile is represented by a position and the number of fruits available at that position. The input array fruits is already sorted by position, and every position is unique.

leetcodehardarraybinary-searchsliding-windowprefix-sum
LeetCode 3240 - Minimum Number of Flips to Make Binary Grid Palindromic II

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

leetcodemediumarraytwo-pointersmatrix
LeetCode 1857 - Largest Color Value in a Directed Graph

The problem asks us to find the largest color value along any path in a directed graph of n nodes, where each node has a color represented by a lowercase English letter. The graph may contain cycles, in which case the function should return -1.

leetcodehardhash-tablestringdynamic-programminggraph-theorytopological-sortmemoizationcounting
CF 173B - Chamber of Secrets

The Chamber of Secrets is represented as a grid of size n by m, where each cell is either empty or contains a column. A basilisk is stationed in the bottom-right corner and looks left, while a person trying to enter starts at the top-left corner and looks right.

codeforcescompetitive-programmingdfs-and-similarshortest-paths
CF 226C - Anniversary

We are asked to work with a contiguous range of integers from l to r, and for every possible subset of size k within this range, we consider the Fibonacci numbers at positions given by the subset elements.

codeforcescompetitive-programmingdata-structuresimplementationmathmatricesnumber-theory
LeetCode 3079 - Find the Sum of Encrypted Integers

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

leetcodeeasyarraymath