brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 226E - Noble Knight's Path

In this problem, we are asked to simulate a sequence of events in a feudal hierarchy represented as a tree. Each feudal owns a castle, and except for the king, each feudal reports to exactly one superior.

codeforcescompetitive-programmingdata-structurestrees
CF 226A - Flying Saucer Segments

We are asked to calculate the minimum time required for a group of n aliens to move from the third section of a three-section spacecraft to the first section.

codeforcescompetitive-programmingmath
LeetCode 2823 - Deep Object Filter

This problem asks us to recursively filter a JSON-like structure that may contain nested objects and arrays. The input consists of two parts: - obj, which can be either: - a primitive value, - an array, - or an object containing nested arrays and objects - fn, a predicate…

leetcodemedium
LeetCode 2877 - Create a DataFrame from List

This problem asks us to create a Pandas DataFrame from a given two dimensional list named studentdata. Each element of studentdata is itself a list containing exactly two values: 1. A student ID 2. The student's age For example: represents four students.

leetcodeeasy
CF 204B - Little Elephant and Cards

We have a collection of cards, each with a front color and a back color. Initially, all cards lie with the front side up. The goal is to make at least half of the cards show the same color on the upper side.

codeforcescompetitive-programmingbinary-searchdata-structures
LeetCode 3308 - Find Top Performing Driver

The problem asks us to identify the top-performing driver for each fuel type based on the trips data. We are given three tables: Drivers, Vehicles, and Trips. Each driver may operate one or more vehicles, and each vehicle may have multiple trips.

leetcodemediumdatabase
LeetCode 2673 - Make Costs of Paths Equal in a Binary Tree

Edit This problem gives us a perfect binary tree with n nodes, where each node has an associated cost. The tree follows a strict indexing rule: node i has a left child at 2 i and a right child at 2 i + 1.

leetcodemediumarraydynamic-programminggreedytreebinary-tree
LeetCode 2403 - Minimum Time to Kill All Monsters

The problem is asking us to compute the minimum number of days required to defeat all monsters in an array power, where power[i] represents the strength of the i-th monster. You start with zero mana and gain mana daily, with the initial daily gain of 1.

leetcodehardarraydynamic-programmingbit-manipulationbitmask
CF 242B - Big Segment

We are given a list of segments on a number line, each defined by a left and right endpoint. The task is to find if there exists a single segment among them that fully contains every other segment.

codeforcescompetitive-programmingimplementationsortings
LeetCode 2259 - Remove Digit From Number to Maximize Result

The problem gives us a string called number, which represents a positive integer, and a character digit, which is guaranteed to appear at least once inside number.

leetcodeeasystringgreedyenumeration
LeetCode 2635 - Apply Transform Over Each Element in Array

This problem asks us to implement a custom version of the array transformation operation, similar to JavaScript’s Array.map, but without using the built in Array.map method. We are given two inputs: 1. An integer array arr 2.

leetcodeeasy
CF 248C - Robo-Footballer

We are working inside a rectangular football field where the left side contains a goal segment on the vertical line $x = 0$, and the right side contains a horizontal wall at height $y = yw$.

codeforcescompetitive-programmingbinary-searchgeometry
LeetCode 2629 - Function Composition

This problem asks us to implement function composition. We are given an array of functions and must return a new function that combines all of them into a single callable function.

leetcodeeasy
LeetCode 3014 - Minimum Number of Pushes to Type Word I

We are given a word consisting of distinct lowercase English letters. We are allowed to completely redesign the mapping of letters onto the telephone keypad keys 2 through 9. There are 8 available keys (2 to 9).

leetcodeeasymathstringgreedy
LeetCode 2768 - Number of Black Blocks

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

leetcodemediumarrayhash-tableenumeration
LeetCode 3072 - Distribute Elements Into Two Arrays II

This problem requires simulating the distribution of elements from a 1-indexed array nums into two separate arrays arr1 and arr2 under specific rules.

leetcodehardarraybinary-indexed-treesegment-treesimulation
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
CF 233A - Perfect Permutation

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

codeforcescompetitive-programmingimplementationmath
LeetCode 2659 - Make Array Empty

The problem gives us an array of distinct integers and defines two possible operations: 1. If the first element is currently the smallest value in the array, we remove it. 2. Otherwise, we move the first element to the end of the array.

leetcodehardarraybinary-searchgreedybinary-indexed-treesegment-treesortingordered-set
CF 150C - Smart Cheater

We have a straight bus route with fixed stop coordinates. A passenger normally pays the full distance between their boarding and exit stops. The conductor is allowed to "hide" at most one continuous segment of that trip from the ticket.

codeforcescompetitive-programmingdata-structuresmathprobabilities
LeetCode 2789 - Largest Element in an Array after Merge Operations

The problem gives us an array of positive integers and allows a special merge operation between adjacent elements.

leetcodemediumarraygreedy
LeetCode 2553 - Separate the Digits in an Array

This problem asks us to take an array of positive integers, nums, and transform it into another array, answer, where each element of nums is broken down into its constituent digits in order.

leetcodeeasyarraysimulation
LeetCode 1928 - Minimum Cost to Reach Destination in Time

The problem asks us to find the minimum cost to travel from city 0 to city n-1 within a given time limit, maxTime, where the cost is defined by passing fees associated with each city visited. The country has n cities connected by bi-directional roads with varying travel times.

leetcodehardarraydynamic-programminggraph-theory
LeetCode 3198 - Find Cities in Each State

This problem provides a database table named cities, where each row represents a relationship between a state and one of its cities.

leetcodeeasydatabase
LeetCode 2911 - Minimum Changes to Make K Semi-palindromes

The problem asks us to partition a given string s into k contiguous substrings and modify the characters minimally so that each substring becomes a semi-palindrome.

leetcodehardtwo-pointersstringdynamic-programming
LeetCode 2634 - Filter Elements from Array

The problem asks us to implement a function that filters an array based on a custom condition defined by another function fn.

leetcodeeasy
CF 181A - Series of Crimes

We are given a map of a city as an n × m grid, where each cell represents a district. Three of the districts have been robbed, marked by , and all other districts are empty (.).

codeforcescompetitive-programmingbrute-forcegeometryimplementation
CF 172A - Phone Code

We are given a list of phone numbers from friends in a city. Each phone number is a string of digits, and all numbers have the same length. The task is to find the city phone code, which Polycarpus defines as the longest common prefix shared by all these numbers.

codeforcescompetitive-programming*specialbrute-forceimplementation
LeetCode 2282 - Number of People That Can Be Seen in a Grid

The problem asks us to determine, for each person in a 2D grid of heights, how many other people they can see according to a specific line-of-sight rule.

leetcodemediumarraystackmatrixmonotonic-stack
LeetCode 2625 - Flatten Deeply Nested Array

This problem is implemented in JavaScript on LeetCode, but you requested Python and Go reference solutions. Since the original stub uses JavaScript-style nested arrays with mixed integer/array values, I will model the structure idiomatically in Python and Go while keeping the…

leetcodemedium
LeetCode 2631 - Group By

The problem asks us to enhance arrays such that any array can call a groupBy method with a callback function fn. This function will determine the key for grouping each element.

leetcodemedium
LeetCode 2428 - Maximum Sum of an Hourglass

The problem provides an m x n integer matrix grid and asks for the maximum sum of an hourglass shape within the matrix. An hourglass is defined as a 3x3 structure with the top and bottom rows fully included, and only the center element from the middle row.

leetcodemediumarraymatrixprefix-sum
LeetCode 3383 - Minimum Runes to Add to Cast Spell

We are given a directed graph with n focus points, numbered from 0 to n - 1. Some focus points already contain magic crystals. These are the starting sources of magic energy. Directed runes represent one-way magic flow between focus points.

leetcodehardarraydepth-first-searchbreadth-first-searchunion-findgraph-theorytopological-sort
CF 447B - DZY Loves Strings

We are given a string made of lowercase letters and a way to assign a numerical weight to each letter. The value of a full string is computed by summing, over all positions, the product of the position index (starting from 1) and the weight of the character at that position.

codeforcescompetitive-programminggreedyimplementation
CF 328A - IQ Test

We are given exactly four integers in a sequence, each between 1 and 1000. The goal is to determine whether this sequence forms an arithmetic progression or a geometric progression. If it does, we must compute the next element of the progression.

codeforcescompetitive-programmingimplementation
LeetCode 2274 - Maximum Consecutive Floors Without Special Floors

The problem gives us a range of rented floors in a building, from bottom to top, inclusive. Within this range, some floors are marked as special floors and cannot be counted as regular office floors.

leetcodemediumarraysorting
LeetCode 3374 - First Letter Capitalization II

This problem asks us to transform text stored in a database table while preserving the original formatting structure. The table usercontent contains two columns: a unique contentid and a contenttext string.

leetcodeharddatabase
LeetCode 3164 - Find the Number of Good Pairs II

We are given two integer arrays, nums1 and nums2, along with a positive integer k. A pair of indices (i, j) is considered good if: In other words, nums1[i] must be divisible by nums2[j] k. The task is to count how many such index pairs exist.

leetcodemediumarrayhash-table
LeetCode 2657 - Find the Prefix Common Array of Two Arrays

The problem provides two arrays, A and B, each a permutation of integers from 1 to n. A permutation means each number from 1 to n appears exactly once in the array.

leetcodemediumarrayhash-tablebit-manipulation
CF 138A - Literature Lesson

Each poem is divided into quatrains, groups of four lines. Two lines rhyme if the suffix starting from the k-th vowel from the end is identical in both lines. For example, with k = 1, we compare suffixes starting at the last vowel.

codeforcescompetitive-programmingimplementation
LeetCode 2404 - Most Frequent Even Element

The problem asks us to identify the most frequent even number in an integer array nums. If multiple even numbers share the highest frequency, we should return the smallest among them. If the array contains no even numbers, the function should return -1.

leetcodeeasyarrayhash-tablecounting
LeetCode 1942 - The Number of the Smallest Unoccupied Chair

This problem describes a scenario where a group of friends attends a party with an infinite number of chairs labeled from 0 upwards. Each friend has a specific arrival and leaving time. When a friend arrives, they must occupy the smallest-numbered unoccupied chair.

leetcodemediumarrayhash-tableheap-(priority-queue)
LeetCode 2378 - Choose Edges to Maximize Score in a Tree

This will be very large if done comprehensively and correctly under your formatting rules, likely exceeding a practical single-message limit and risking truncation or reduced quality.

leetcodemediumdynamic-programmingtreedepth-first-search
LeetCode 3142 - Check if Grid Satisfies Conditions

The problem gives us a two dimensional matrix called grid with m rows and n columns. We must verify whether every cell satisfies two separate rules. The first rule applies vertically. For every cell, if there is a cell directly below it, both values must be equal.

leetcodeeasyarraymatrix
LeetCode 3266 - Final Array State After K Multiplication Operations II

The problem gives us an integer array nums, an integer k, and an integer multiplier. We must perform exactly k operations on the array. In each operation, we locate the minimum value currently present in the array.

leetcodehardarrayheap-(priority-queue)simulation
LeetCode 2535 - Difference Between Element Sum and Digit Sum of an Array

The problem gives us an array of positive integers called nums. We need to compute two different values from this array. The first value is the element sum, which is simply the sum of every number in the array.

leetcodeeasyarraymath
LeetCode 3312 - Sorted GCD Pair Queries

=== 1996-G1 === Origin: GBR Let triangle have orthocenter , and let be a point on its circumcircle, distinct from , , . Let be the foot of the altitude , let and be parallelograms, and let meet in . Prove that is parallel to .

leetcodehardarrayhash-tablemathbinary-searchcombinatoricscountingnumber-theoryprefix-sum
LeetCode 2389 - Longest Subsequence With Limited Sum

This problem asks us to determine, for each query, the maximum number of elements we can select from an array nums such that their sum does not exceed a given value.

leetcodeeasyarraybinary-searchgreedysortingprefix-sum
LeetCode 2572 - Count the Number of Square-Free Subsets

The problem asks us to count all non-empty subsets of a given array nums such that the product of the elements in each subset is square-free. A square-free integer is an integer not divisible by the square of any prime greater than 1.

leetcodemediumarraymathdynamic-programmingbit-manipulationnumber-theorybitmask
CF 160C - Find Pair

We are given an array of n integers. From this array, we form every ordered pair (a[i], a[j]), including pairs where i = j. Since both positions are chosen independently, there are exactly n² pairs. All these pairs are sorted lexicographically.

codeforcescompetitive-programmingimplementationmathsortings
LeetCode 2731 - Movement of Robots

The problem gives us a list of robots positioned on an infinite number line. Each robot starts at a unique coordinate from the array nums, and each robot has an associated movement direction from the string s. A robot moves exactly one unit per second.

leetcodemediumarraybrainteasersortingprefix-sum
LeetCode 2683 - Neighboring Bitwise XOR

The problem presents us with a binary array called derived of length n. This array is constructed from another binary array original of the same length using the bitwise XOR operation on adjacent elements.

leetcodemediumarraybit-manipulation
LeetCode 2891 - Method Chaining

This problem provides a Pandas DataFrame named animals with four columns: | Column | Type | | --- | --- | | name | object | | species | object | | age | int | | weight | int | The task is to return a new DataFrame containing only the names of animals whose weight is strictly…

leetcodeeasy
LeetCode 3161 - Block Placement Queries

The problem involves simulating operations on an infinite number line starting at 0 and extending towards the positive x-axis.

leetcodehardarraybinary-searchbinary-indexed-treesegment-tree
LeetCode 3400 - Maximum Number of Matching Indices After Right Shifts

The problem gives us two arrays, nums1 and nums2, both of the same length n. We are allowed to repeatedly perform a right circular shift on nums1. A right shift moves every element one position to the right, and the last element wraps around to the beginning.

leetcodemediumarraytwo-pointerssimulation
LeetCode 2310 - Sum of Numbers With Units Digit K

This problem asks us to construct a set of positive integers such that: 1. Every number in the set has a units digit equal to k. 2. The sum of all numbers equals num. 3. We want the smallest possible number of integers in the set.

leetcodemediummathdynamic-programminggreedyenumeration
CF 162H - Alternating case

We are given a single string containing English letters in arbitrary capitalization. The task is to rewrite the string so that characters at odd positions become uppercase and characters at even positions become lowercase. The positions are counted starting from 1, not from 0.

codeforcescompetitive-programming*special
LeetCode 2906 - Construct Product Matrix

The problem asks us to construct a new matrix p from a given matrix grid. For every position (i, j), the value p[i][j] must equal the product of every element in the matrix except grid[i][j], and the result must be taken modulo 12345.

leetcodemediumarraymatrixprefix-sum
LeetCode 2831 - Find the Longest Equal Subarray

The problem asks us to find the longest contiguous subarray where all elements are equal, after we are allowed to delete at most k elements from the original array.

leetcodemediumarrayhash-tablebinary-searchsliding-window
LeetCode 2804 - Array Prototype ForEach

This problem asks us to implement a custom version of the forEach method for arrays in JavaScript. The goal is to extend the Array.prototype so that any array can call forEach(callback, context) and execute the callback on each element.

leetcodeeasy
LeetCode 2509 - Cycle Length Queries in a Tree

The problem gives us a complete binary tree where nodes are labeled in the same way as a binary heap. For every node with value x: - Its left child is 2 x - Its right child is 2 x + 1 The tree contains all node values from 1 to 2^n - 1.

leetcodehardarraytreebinary-tree
LeetCode 3278 - Find Candidates for Data Scientist Position II

This problem asks us to determine the best candidate for every project based on required skills and a scoring system. We are given two database tables. The Candidates table stores information about each candidate's skills and proficiency levels.

leetcodemediumdatabase
CF 446E - DZY Loves Bridges

We are dealing with a very large directed walk-counting problem on a graph that is heavily structured but too large to ever build explicitly. There are $2m$ islands, and DZY starts from a home node. From home, he can move to island $i$ in $ai$ different ways.

codeforcescompetitive-programmingmathmatrices
CF 241C - Mirror Box

The system describes a rectangular box where a laser beam enters through one small hole on the left wall and must exit through another hole on the right wall. Inside the box, there are horizontal mirror segments placed either on the floor or on the ceiling.

codeforcescompetitive-programminggeometryimplementation
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
LeetCode 2600 - K Items With the Maximum Sum

The problem asks us to determine the maximum possible sum when picking exactly k items from a bag containing items labeled 1, 0, or -1.

leetcodeeasymathgreedy
LeetCode 2628 - JSON Deep Equal

The problem asks us to determine whether two JSON values, o1 and o2, are deeply equal. Deep equality goes beyond simple reference or shallow equality. For primitive values such as numbers, strings, booleans, or null, equality is straightforward using strict comparison (===).

leetcodemedium
LeetCode 2525 - Categorize Box According to Criteria

The problem requires categorizing a box based on its dimensions and mass according to given criteria. We are given four integers: length, width, height, and mass. The output is a string that represents the category of the box: "Bulky", "Heavy", "Both", or "Neither".

leetcodeeasymath
CF 191D - Metro Scheme

We are given an undirected connected graph describing a subway system. Every edge is a tunnel, every vertex is a station. The graph is guaranteed to be a vertex cactus, meaning each vertex belongs to at most one simple cycle. The subway is composed of lines of two possible types.

codeforcescompetitive-programminggraphsgreedy
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
CF 225B - Well-known Numbers

We are given two integers, s and k. The task is to express s as a sum of distinct numbers taken from the k-bonacci sequence. The sequence behaves like Fibonacci, but instead of summing the previous two values, each term is the sum of the previous k terms.

codeforcescompetitive-programmingbinary-searchgreedynumber-theory
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 2797 - Partial Function with Placeholders

The problem is asking us to implement a function partial that takes a target function fn and a list of arguments args. Some of these arguments may be placeholders represented by the string "".

leetcodeeasy
CF 145D - Lucky Pair

We are given an array of integers, and some of these integers are "lucky numbers," meaning they consist only of the digits 4 and 7.

codeforcescompetitive-programmingcombinatoricsdata-structuresimplementation
CF 445A - DZY Loves Chessboard

We are given a chessboard represented as an n by m grid where each cell is either good or bad. A good cell is indicated by a "." and a bad cell by a "-".

codeforcescompetitive-programmingdfs-and-similarimplementation
LeetCode 2144 - Minimum Cost of Buying Candies With Discount

This problem asks us to minimize the total amount of money spent when buying candies under a special discount rule. For every two candies that are purchased, we may take one additional candy for free.

leetcodeeasyarraygreedysorting
LeetCode 1917 - Leetcodify Friends Recommendations

This problem requires generating friend recommendations for users on the Leetcodify platform based on their listening habits. We are given two tables: Listens and Friendship.

leetcodeharddatabase
LeetCode 2951 - Find the Peaks

The problem is asking us to identify all the peaks in a given array mountain. A peak is an element that is strictly greater than its immediate neighbors. Importantly, the first and last elements of the array cannot be peaks because they do not have two neighbors.

leetcodeeasyarrayenumeration
LeetCode 2220 - Minimum Bit Flips to Convert Number

The problem asks us to determine the minimum number of bit flips required to transform an integer start into another integer goal. A bit flip is defined as changing a single bit in the binary representation of a number from 0 to 1 or from 1 to 0.

leetcodeeasybit-manipulation
LeetCode 2547 - Minimum Cost to Split an Array

The problem asks us to split the array nums into one or more contiguous non-empty subarrays such that the total cost is minimized. For every subarray, we define a special quantity called its importance value.

leetcodehardarrayhash-tabledynamic-programmingcounting
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
CF 431C - k-Tree

We are working with a rooted infinite tree where every node always has exactly $k$ outgoing edges to children. Each of those $k$ edges has a fixed weight: the first is 1, the second is 2, and so on up to $k$.

codeforcescompetitive-programmingdpimplementationtrees
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
LeetCode 2876 - Count Visited Nodes in a Directed Graph

The problem presents a directed graph with n nodes, where each node has exactly one outgoing edge defined by the array edges. Specifically, edges[i] indicates that there is a directed edge from node i to node edges[i].

leetcodeharddynamic-programmingdepth-first-searchgraph-theorytopological-sortmemoization
LeetCode 3291 - Minimum Number of Valid Strings to Form Target I

We are given a list of strings called words and another string called target. The task is to construct target by concatenating several smaller strings, where each smaller string must be a prefix of at least one word in words. A prefix means the beginning portion of a word.

leetcodemediumarraystringbinary-searchdynamic-programminggreedytriesegment-treerolling-hashstring-matchinghash-function
LeetCode 1986 - Minimum Number of Work Sessions to Finish the Tasks

This problem asks us to schedule a collection of tasks into the minimum number of work sessions. Each task has a fixed duration, and every work session has a maximum allowed length, sessionTime. A task cannot be split across multiple sessions.

leetcodemediumarraydynamic-programmingbacktrackingbit-manipulationbitmask
LeetCode 3223 - Minimum Length of String After Operations

The problem asks us to repeatedly remove characters from a string based on a specific rule. Specifically, for any character s[i] in the string, we can remove the nearest occurrence of the same character to the left of i and the nearest occurrence to the right of i.

leetcodemediumhash-tablestringcounting
LeetCode 1887 - Reduction Operations to Make the Array Elements Equal

This problem asks us to make all elements in an integer array equal by repeatedly reducing the largest elements to the next largest element in the array.

leetcodemediumarraysorting
LeetCode 1853 - Convert Date Format

The problem provides a database table named Days with a single column called day. Each value in this column is a valid SQL DATE, and every value is unique.

leetcodeeasydatabase
LeetCode 2357 - Make Array Zero by Subtracting Equal Amounts

This problem gives us an array nums containing non-negative integers. We want to transform the entire array into zeros using a specific operation.

leetcodeeasyarrayhash-tablegreedysortingheap-(priority-queue)simulation
LeetCode 3026 - Maximum Good Subarray Sum

The problem asks us to find the maximum possible sum of a contiguous subarray where the absolute difference between the first and last element of that subarray is exactly k. More formally, for a subarray nums[i..

leetcodemediumarrayhash-tableprefix-sum
LeetCode 3122 - Minimum Number of Operations to Satisfy Conditions

The problem presents a two-dimensional matrix grid of size m x n with integer values in the range 0 to 9. The task is to transform this matrix using the minimum number of operations, where each operation allows you to change the value of any cell to any non-negative integer.

leetcodemediumarraydynamic-programmingmatrix
CF 429E - Points and Segments

We are given a collection of segments on a number line. Each segment spans from a left endpoint to a right endpoint, and we must assign each segment one of two colors.

codeforcescompetitive-programminggraphs
LeetCode 3281 - Maximize Score of Numbers in Ranges

The problem presents a list of intervals derived from the start array and a fixed d. Specifically, each interval is [start[i], start[i] + d].

leetcodemediumarraybinary-searchgreedysorting
LeetCode 3257 - Maximum Value Sum by Placing Three Rooks II

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

leetcodehardarraydynamic-programmingmatrixenumeration
LeetCode 3067 - Count Pairs of Connectable Servers in a Weighted Tree Network

The problem gives us a weighted tree representing servers connected by edges with weights. The servers are numbered from 0 to n-1. Each edge has a weight representing distance or cost.

leetcodemediumarraytreedepth-first-search
LeetCode 2738 - Count Occurrences in Text

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

leetcodemediumdatabase
LeetCode 1874 - Minimize Product Sum of Two Arrays

The problem defines the product sum of two arrays as the sum of the products of corresponding elements at the same indices. If we have arrays a and b, then the product sum is: We are given two arrays, nums1 and nums2, both of the same length n.

leetcodemediumarraygreedysorting
LeetCode 2992 - Number of Self-Divisible Permutations

The problem asks us to count how many permutations of the numbers 1 through n satisfy a special condition called self-divisible. We start with the array: We must rearrange these numbers into every possible permutation, then determine whether the permutation is valid.

leetcodemediumarraymathdynamic-programmingbacktrackingbit-manipulationnumber-theorybitmask
LeetCode 2057 - Smallest Index With Equal Value

The problem gives us a 0-indexed integer array nums. We must find the smallest index i such that: The expression i mod 10 means the remainder when i is divided by 10. We are asked to scan the array and determine whether any index satisfies this condition.

leetcodeeasyarray