brain

tamnd's digital brain — notes, problems, research

43815 notes

LeetCode 2021 - Brightest Position on Street

The problem asks us to find the position on a straight street that is illuminated by the largest number of street lamps, which is referred to as its brightness.

leetcodemediumarraysortingprefix-sumordered-set
LeetCode 957 - Prison Cells After N Days

The problem presents a simulation scenario with a row of exactly 8 prison cells, where each cell is either occupied (1) or vacant (0). Each day, the state of a cell changes based on the states of its immediate neighbors.

leetcodemediumarrayhash-tablemathbit-manipulation
LeetCode 1314 - Matrix Block Sum

The problem requires computing a matrix block sum. Given a matrix mat of size m x n and an integer k, the task is to pro

leetcodemediumarraymatrixprefix-sum
LeetCode 465 - Optimal Account Balancing

The problem gives a list of money transfers between people. Each transaction is represented as [from, to, amount], meaning one person paid a certain amount to another person.

leetcodehardarraydynamic-programmingbacktrackingbit-manipulationbitmask
LeetCode 1231 - Divide Chocolate

The problem asks us to divide a chocolate bar into k + 1 consecutive pieces such that we maximize the minimum total sweetness among those pieces. Each element in the input array sweetness represents the sweetness of a single chunk.

leetcodehardarraybinary-search
LeetCode 443 - String Compression

The problem asks us to perform in place string compression on an array of characters. The input is not a string object, but a mutable array named chars, where each element is a single character. The compression rule is based on groups of consecutive repeated characters.

leetcodemediumtwo-pointersstring
LeetCode 253 - Meeting Rooms II

The problem gives us a list of meeting intervals where each interval is represented as [start, end]. Each interval describes the time range during which a meeting occupies a conference room.

leetcodemediumarraytwo-pointersgreedysortingheap-(priority-queue)prefix-sum
LeetCode 378 - Kth Smallest Element in a Sorted Matrix

The problem gives us an n x n matrix where both rows and columns are sorted in ascending order. This means two ordering guarantees exist simultaneously: - Every row is sorted from left to right. - Every column is sorted from top to bottom.

leetcodemediumarraybinary-searchsortingheap-(priority-queue)matrix
LeetCode 2025 - Maximum Number of Ways to Partition an Array

The problem asks us to count how many valid partition points exist in an array after optionally changing at most one element to a given value k.

leetcodehardarrayhash-tablecountingenumerationprefix-sum
LeetCode 1491 - Average Salary Excluding the Minimum and Maximum Salary

The problem gives us an array called salary, where each element represents the salary of an employee. Every salary value

leetcodeeasyarraysorting
LeetCode 1824 - Minimum Sideway Jumps

This problem describes a frog navigating a 3-lane road of length n. The frog starts at point 0 in lane 2 and wants to reach point n. Each point along the road may have at most one obstacle in one of the three lanes, represented by the obstacles array.

leetcodemediumarraydynamic-programminggreedy
LeetCode 932 - Beautiful Array

The problem asks us to construct a permutation of the integers from 1 to n such that the array satisfies a special condition.

leetcodemediumarraymathdivide-and-conquer
LeetCode 975 - Odd Even Jump

The problem asks us to determine how many starting indices in an array allow reaching the last element by performing a series of jumps defined as either odd-numbered or even-numbered.

leetcodehardarraydynamic-programmingstacksortingmonotonic-stackordered-set
LeetCode 982 - Triples with Bitwise AND Equal To Zero

This problem asks us to count the number of triples (i, j, k) from an integer array nums such that the bitwise AND of the three numbers at these indices equals zero. In other words, we want all combinations where nums[i] & nums[j] & nums[k] == 0.

leetcodehardarrayhash-tablebit-manipulation
LeetCode 335 - Self Crossing

The problem describes a path traced on a two-dimensional grid. We begin at the origin (0, 0) and move according to the values in the distance array.

leetcodehardarraymathgeometry
LeetCode 1259 - Handshakes That Don't Cross

In this problem, we are given an even number of people standing around a circle. Every person must participate in exactl

leetcodehardmathdynamic-programming
LeetCode 1251 - Average Selling Price

This problem asks us to compute the average selling price for every product based on two tables: Prices and UnitsSold. T

leetcodeeasydatabase
CF 73C - LionAge II

We are given a string representing a character's name in a game, and we can change at most k of its letters to maximize a score called euphony. The euphony is computed as the sum of bonuses for every consecutive pair of letters in the string.

codeforcescompetitive-programmingdp
LeetCode 1792 - Maximum Average Pass Ratio

The problem gives us several classes, where each class is represented as [passi, totali]. The value passi tells us how many students currently pass the exam, while totali tells us the total number of students in that class.

leetcodemediumarraygreedyheap-(priority-queue)
LeetCode 1791 - Find Center of Star Graph

The problem is asking us to identify the center node of a star graph. A star graph is a very specific type of graph with n nodes: there is one node called the center, and it is connected to all other n-1 nodes.

leetcodeeasygraph-theory
LeetCode 374 - Guess Number Higher or Lower

The problem describes a classic interactive guessing game. A hidden number called pick is chosen somewhere in the range from 1 to n, inclusive. We are not allowed to access pick directly.

leetcodeeasybinary-searchinteractive
LeetCode 1365 - How Many Numbers Are Smaller Than the Current Number

The problem asks us to determine, for each element in an array, how many elements in the same array are strictly smaller than it. In other words, for an element nums[i], we count all elements nums[j] such that nums[j] < nums[i] and j != i.

leetcodeeasyarrayhash-tablesortingcounting-sort
CF 95C - Volleyball

The problem presents a weighted undirected graph where nodes represent junctions and edges represent roads with a given length. At each junction, there is a taxi that can carry a passenger up to a maximum distance and charges a fixed cost.

codeforcescompetitive-programmingshortest-paths
LeetCode 1237 - Find Positive Integer Solution for a Given Equation

This problem gives us access to a hidden function f(x, y) through an interface. We are not allowed to know or implement the formula directly. Instead, we can only call the function with positive integers x and y and observe the result.

leetcodemediummathtwo-pointersbinary-searchinteractive
CF 4D - Mysterious Present

We are given a collection of envelopes, each with a width and height. A postcard already has fixed dimensions, and we want to build the longest possible nesting chain of envelopes such that:

codeforcescompetitive-programmingdpsortings
LeetCode 1038 - Binary Search Tree to Greater Sum Tree

The problem gives us the root of a Binary Search Tree, abbreviated as BST, and asks us to transform it into a Greater Sum Tree. In a Binary Search Tree, every node follows an important ordering rule: - All values in the left subtree are smaller than the current node.

leetcodemediumtreedepth-first-searchbinary-search-treebinary-tree
LeetCode 1378 - Replace Employee ID With The Unique Identifier

This problem asks us to combine information from two database tables and return the result in a specific format. We are

leetcodeeasydatabase
LeetCode 1756 - Design Most Recently Used Queue

The problem asks us to design a special queue called an "Most Recently Used Queue", abbreviated as MRUQueue. Initially, the queue contains the integers from 1 to n in increasing order. The key operation is fetch(k), where k is 1-indexed. This operation does two things: 1.

leetcodemediumarraylinked-listdivide-and-conquerdesignsimulationdoubly-linked-list
LeetCode 76 - Minimum Window Substring

The problem asks us to find the smallest contiguous substring inside string s that contains every character from string t, including duplicate occurrences. A substring must consist of consecutive characters. We are not allowed to reorder characters or skip positions.

leetcodehardhash-tablestringsliding-window
LeetCode 1249 - Minimum Remove to Make Valid Parentheses

The problem is asking us to process a string containing lowercase letters and parentheses, and remove the minimum number of parentheses so that the remaining string is valid.

leetcodemediumstringstack
LeetCode 1669 - Merge In Between Linked Lists

The problem asks us to merge two singly linked lists in a very specific way. We are given list1 and list2, with sizes n

leetcodemediumlinked-list
LeetCode 749 - Contain Virus

This problem models the spread of a virus on a two-dimensional grid. Each cell is either infected (1) or uninfected (0). The virus spreads every night from infected cells to adjacent uninfected cells in the four cardinal directions: up, down, left, and right.

leetcodehardarraydepth-first-searchbreadth-first-searchmatrixsimulation
LeetCode 323 - Number of Connected Components in an Undirected Graph

The problem asks us to determine how many connected components exist in an undirected graph. A connected component is a group of nodes where every node can reach every other node through some path.

leetcodemediumdepth-first-searchbreadth-first-searchunion-findgraph-theory
LeetCode 905 - Sort Array By Parity

The problem asks us to rearrange an array so that all even numbers appear before all odd numbers. The relative ordering among even numbers does not matter, and the relative ordering among odd numbers also does not matter.

leetcodeeasyarraytwo-pointerssorting
LeetCode 1206 - Design Skiplist

This problem asks us to implement a Skiplist from scratch, a probabilistic data structure that allows efficient search, insertion, and deletion operations.

leetcodehardlinked-listdesign
LeetCode 550 - Game Play Analysis IV

This problem is asking us to calculate a retention metric from a table of player activities. Specifically, we need to determine the fraction of players who log in on the day immediately following their first login.

leetcodemediumdatabase
CF 20C - Dijkstra?

We are given an undirected weighted graph. Every edge connects two vertices and has a positive cost. The task is to start at vertex 1, reach vertex n, and print one shortest path. If no route exists, we print -1.

codeforcescompetitive-programminggraphsshortest-paths
LeetCode 1236 - Web Crawler

The problem asks us to implement a simplified web crawler. We are given a starting URL and access to an HtmlParser interface that can retrieve all URLs linked from a given webpage.

leetcodemediumstringdepth-first-searchbreadth-first-searchinteractive
LeetCode 500 - Keyboard Row

This problem asks us to determine which words in a given list can be typed using letters from only one row of an American keyboard. The input is an array of strings, words, where each string represents a word consisting only of English alphabet characters.

leetcodeeasyarrayhash-tablestring
LeetCode 1846 - Maximum Element After Decreasing and Rearranging

The problem provides an array of positive integers and asks us to perform operations to transform it so that two conditions are satisfied: the first element must be 1, and the absolute difference between adjacent elements cannot exceed 1.

leetcodemediumarraygreedysorting
LeetCode 130 - Surrounded Regions

The problem gives us a two dimensional grid called board, where each cell contains either 'X' or 'O'. The goal is to modify the board in place by capturing every region of 'O' cells that is completely surrounded by 'X'.

leetcodemediumarraydepth-first-searchbreadth-first-searchunion-findmatrix
CF 75D - Big Maximum Sum

We are given a set of small arrays and a sequence of indexes indicating how to concatenate them into one larger array. Once the large array is built in this way, the goal is to find the maximum sum of a contiguous subarray.

codeforcescompetitive-programmingdata-structuresdpgreedyimplementationmathtrees
LeetCode 359 - Logger Rate Limiter

The problem asks us to design a logging system that controls how frequently identical messages can be printed. Each message is associated with a timestamp, and the same message is only allowed to be printed once every 10 seconds.

leetcodeeasyhash-tabledesigndata-stream
LeetCode 1309 - Decrypt String from Alphabet to Integer Mapping

The problem gives us a string containing digits and the '' character. This string encodes lowercase English letters usin

leetcodeeasystring
LeetCode 39 - Combination Sum

This problem asks us to generate every possible unique combination of numbers from the given candidates array such that the sum of the chosen numbers equals target. There are several important details in the problem statement: - Every number in candidates is distinct.

leetcodemediumarraybacktracking
CF 123E - Maze

We are given a tree, and two independent probability distributions over its vertices. One distribution chooses the starting vertex of a DFS, the other chooses the target vertex where the search stops.

codeforcescompetitive-programmingdfs-and-similardpprobabilitiestrees
LeetCode 715 - Range Module

This problem asks us to design a data structure that dynamically tracks intervals on the number line. The tracked intervals are represented as half-open intervals, meaning [left, right) includes every value x such that left <= x < right.

leetcodeharddesignsegment-treeordered-set
LeetCode 413 - Arithmetic Slices

The problem asks us to count how many contiguous subarrays of length at least three form an arithmetic sequence. An arithmetic sequence is one where the difference between every pair of adjacent elements is identical.

leetcodemediumarraydynamic-programmingsliding-window
CF 115E - Linear Kingdom Races

We are asked to maximize profit from a set of potential races in a linearly connected kingdom. Each race occupies a contiguous set of roads and provides a payment if all the roads it uses are repaired.

codeforcescompetitive-programmingdata-structuresdp
LeetCode 1295 - Find Numbers with Even Number of Digits

The problem asks us to determine how many numbers in a given array nums have an even number of digits. The input is an a

leetcodeeasyarraymath
LeetCode 1139 - Largest 1-Bordered Square

That is a long, detailed reference document with multiple required sections, complete implementations, worked traces, and test coverage. I can provide the full guide in a single response.

leetcodemediumarraydynamic-programmingmatrix
CF 24B - F1 Champions

We are given the results of an entire Formula One season. Each race lists drivers from first place to last place. The championship winner depends on one of two ranking systems.

codeforcescompetitive-programmingimplementation
CF 16E - Fish

We have n fish in a lake. Every day, exactly one unordered pair of currently alive fish is chosen uniformly at random. When fish i meets fish j, fish i eats fish j with probability a[i][j], and fish j eats fish i with probability a[j][i] = 1 - a[i][j].

codeforcescompetitive-programmingbitmasksdpprobabilities
LeetCode 1547 - Minimum Cost to Cut a Stick

The problem asks us to determine the minimum total cost of cutting a wooden stick into pieces at specified positions. Th

leetcodehardarraydynamic-programmingsorting
LeetCode 1095 - Find in Mountain Array

This problem gives us a special type of array called a mountain array. A mountain array strictly increases until it reaches a single peak element, then strictly decreases afterward. For example: increases up to 5, then decreases.

leetcodehardarraybinary-searchinteractive
LeetCode 869 - Reordered Power of 2

The problem gives us a positive integer n and asks whether its digits can be rearranged to form a power of two. The rearrangement may keep the digits in their original order or place them in any other order, but the resulting number cannot contain a leading zero.

leetcodemediumhash-tablemathsortingcountingenumeration
LeetCode 2003 - Smallest Missing Genetic Value in Each Subtree

This problem asks us to compute, for every node in a rooted tree, the smallest positive integer that does not appear in the subtree rooted at that node. We are given two arrays: parents describes the tree structure, and nums contains distinct genetic values assigned to each node.

leetcodehardarraydynamic-programmingtreedepth-first-searchunion-find
LeetCode 895 - Maximum Frequency Stack

The problem is asking us to design a custom stack-like data structure that supports two operations: pushing values onto the stack and popping the most frequent element.

leetcodehardhash-tablestackdesignordered-set
LeetCode 651 - 4 Keys Keyboard

The problem gives us a keyboard with four operations: - Press A, which inserts one character 'A' - Press Ctrl-A, which selects everything currently on the screen - Press Ctrl-C, which copies the selected text into a clipboard buffer - Press Ctrl-V, which pastes the clipboard…

leetcodemediummathdynamic-programming
LeetCode 747 - Largest Number At Least Twice of Others

The problem gives us an integer array nums in which the largest value is guaranteed to be unique. Our task is to determine whether this largest number is at least twice as large as every other number in the array.

leetcodeeasyarraysorting
LeetCode 972 - Equal Rational Numbers

The problem asks us to determine whether two strings s and t, each representing a rational number in decimal notation, correspond to the same numerical value. These numbers can be expressed as integers, finite decimals, or decimals with repeating parts denoted by parentheses.

leetcodehardmathstring
CF 30D - King's Problem?

We have n + 1 cities. The first n cities lie on the x-axis at positions (x1, 0), (x2, 0), ..., (xn, 0). One additional city is somewhere off the axis at (x_{n+1}, y_{n+1}).

codeforcescompetitive-programminggeometrygreedy
LeetCode 969 - Pancake Sorting

The problem is asking us to sort an array of unique integers using only pancake flips. A pancake flip is defined as reversing a prefix of the array from index 0 to index k-1 for some integer k between 1 and the length of the array.

leetcodemediumarraytwo-pointersgreedysorting
CF 64H - Table Bowling

We are given the final standings of a table bowling tournament. Every participant has a unique name and an integer score. The task is not just to sort the players, but also to assign ranking labels in the style used in real tournaments.

codeforcescompetitive-programming*specialsortings
CF 13D - Triangles

We have two sets of points on the plane. Red points may be used as triangle vertices, blue points are obstacles. No three points are collinear, which removes all degeneracies involving points on triangle borders.

codeforcescompetitive-programmingdpgeometry
LeetCode 532 - K-diff Pairs in an Array

The problem asks us to count how many unique pairs of integers in the array have an absolute difference equal to k. A pair is considered valid if: - The two elements come from different indices. - The absolute difference between the two values is exactly k.

leetcodemediumarrayhash-tabletwo-pointersbinary-searchsorting
LeetCode 263 - Ugly Number

The problem asks us to determine whether a given integer n is an ugly number. An ugly number is defined as a positive integer whose prime factors are limited to only 2, 3, and 5.

leetcodeeasymath
LeetCode 397 - Integer Replacement

The problem gives us a positive integer n and asks for the minimum number of operations required to transform it into 1.

leetcodemediumdynamic-programminggreedybit-manipulationmemoization
LeetCode 175 - Combine Two Tables

The problem is asking us to combine two relational database tables, Person and Address, in such a way that we report each person's first name, last name, city, and state.

leetcodeeasydatabase
LeetCode 542 - 01 Matrix

This problem gives us an m x n binary matrix where every cell contains either 0 or 1. For every cell in the matrix, we must compute the distance to the nearest cell containing 0. Distance is measured using Manhattan movement with four directions only: up, down, left, and right.

leetcodemediumarraydynamic-programmingbreadth-first-searchmatrix
LeetCode 736 - Parse Lisp Expression

The problem asks us to evaluate a Lisp-like expression represented as a string. The expression can contain integers, variables, and three special operations: let, add, and mult. An expression evaluates to a single integer value.

leetcodehardhash-tablestringstackrecursion
LeetCode 947 - Most Stones Removed with Same Row or Column

The problem gives us a collection of stones placed on a 2D grid. Each stone occupies a unique coordinate (x, y). A stone can be removed only if there is at least one other stone that shares either the same row or the same column.

leetcodemediumhash-tabledepth-first-searchunion-findgraph-theory
LeetCode 1630 - Arithmetic Subarrays

The problem asks us to determine whether subarrays of a given array can be rearranged to form an arithmetic sequence. An

leetcodemediumarrayhash-tablesorting
LeetCode 1623 - All Valid Triplets That Can Represent a Country

The problem asks us to generate all valid triplets of students representing a country from three schools: SchoolA, Schoo

leetcodeeasydatabase
LeetCode 672 - Bulb Switcher II

The problem describes a room containing n light bulbs, where every bulb starts in the on state. There are four buttons available, and each button flips a specific subset of bulbs. Flipping means changing on to off or off to on.

leetcodemediummathbit-manipulationdepth-first-searchbreadth-first-search
CF 129A - Cookies

We are given several bags of cookies, where each bag contains some number of cookies. Olga wants to steal exactly one bag. After removing that bag, the total number of cookies left behind must be even so the two sisters can split them equally.

codeforcescompetitive-programmingimplementation
CF 119A - Epic Game

We are asked to simulate a turn-based game between two players, Simon and Antisimon, who each have a fixed integer, a and b respectively. There is a heap of n stones.

codeforcescompetitive-programmingimplementation
LeetCode 1098 - Unpopular Books

The problem asks us to identify books from a Books table that are considered unpopular based on their sales in the last year, relative to a fixed "today" date of 2019-06-23.

leetcodemediumdatabase
LeetCode 57 - Insert Interval

The problem gives us a list of intervals that are already sorted by starting value and guaranteed to be non-overlapping. Each interval represents a continuous range, written as [start, end].

leetcodemediumarray
LeetCode 1180 - Count Substrings with Only One Distinct Letter

The problem asks us to count how many substrings of a given string contain only one distinct character. A substring is a contiguous section of the string. For example, in the string "aaaba", the substring "aaa" is valid because every character is 'a'.

leetcodeeasymathstring
LeetCode 1109 - Corporate Flight Bookings

The problem is asking us to compute the total number of seats reserved for each flight given a list of flight bookings. Each booking specifies a range of consecutive flights [firsti, lasti] and the number of seats seatsi reserved for each flight in that range.

leetcodemediumarrayprefix-sum
LeetCode 1752 - Check if Array Is Sorted and Rotated

The problem is asking us to determine whether a given array nums could be the result of taking a sorted array in non-decreasing order and then rotating it by some number of positions. A non-decreasing array is one where each element is greater than or equal to the previous one.

leetcodeeasyarray
LeetCode 1375 - Number of Times Binary String Is Prefix-Aligned

The problem asks us to determine how many times a binary string becomes prefix-aligned during a series of bit flips. We

leetcodemediumarray
CF 50C - Happy Farm 5

We have a set of points on a 2D plane representing cows, each with integer coordinates. Vasya, the shepherd, must walk a closed path around all the cows in such a way that every cow lies strictly inside the path. The goal is to minimize the number of moves needed.

codeforcescompetitive-programminggeometry
LeetCode 54 - Spiral Matrix

The problem gives an m x n matrix and asks us to return all elements in spiral order. Spiral order means we start from the top-left corner and move in a clockwise spiral pattern: 1. Traverse the top row from left to right 2. Traverse the right column from top to bottom 3.

leetcodemediumarraymatrixsimulation
LeetCode 136 - Single Number

The problem gives an integer array nums where every value appears exactly twice except for one value that appears only once. The task is to find and return that unique value.

leetcodeeasyarraybit-manipulation
CF 81C - Average Score

We are given a sequence of marks, but the subject for each mark was lost. There are only two subjects, and we know exactly how many marks belong to each one. If subject 1 must receive a marks, then subject 2 automatically receives b = n - a marks.

codeforcescompetitive-programminggreedymathsortings
LeetCode 734 - Sentence Similarity

The problem gives us two sentences, where each sentence is represented as an array of words. We are also given a list of word pairs that define which words are considered similar. Our task is to determine whether the two sentences are similar according to the following rules: 1.

leetcodeeasyarrayhash-tablestring
LeetCode 652 - Find Duplicate Subtrees

The problem gives us the root of a binary tree and asks us to identify all duplicate subtrees inside it. A subtree is defined as any node together with all of its descendants.

leetcodemediumhash-tabletreedepth-first-searchbinary-tree
LeetCode 1051 - Height Checker

The problem gives us an array called heights, where each value represents the height of a student standing in a line. The school wants the students arranged in non-decreasing order, meaning heights should appear from smallest to largest, allowing duplicates.

leetcodeeasyarraysortingcounting-sort
LeetCode 640 - Solve the Equation

The problem is asking us to solve a linear equation containing a single variable 'x' and integer coefficients, expressed as a string. The equation may include addition '+', subtraction '-', and the equality operator '='.

leetcodemediummathstringsimulation
LeetCode 1430 - Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree

The problem asks us to determine whether a given array of integers arr represents a valid sequence from the root to a leaf in a binary tree.

leetcodemediumtreedepth-first-searchbreadth-first-searchbinary-tree
CF 64G - Path Canonization

We are given an absolute Unix-style path. The path is split into components by /, and every component represents either a normal directory or file name, ".", or "..". A normal name means “go into this directory or file”. The component ".

codeforcescompetitive-programming*special
LeetCode 300 - Longest Increasing Subsequence

The problem asks us to find the length of the longest strictly increasing subsequence in an array of integers. A subsequence is formed by deleting zero or more elements from the array without changing the order of the remaining elements.

leetcodemediumarraybinary-searchdynamic-programming
LeetCode 243 - Shortest Word Distance

The problem gives us an array of strings called wordsDict, along with two distinct target words, word1 and word2. Both target words are guaranteed to exist somewhere in the array.

leetcodeeasyarraystring
LeetCode 1522 - Diameter of N-Ary Tree

This problem asks us to compute the diameter of an N-ary tree. An N-ary tree is a tree where each node can have any numb

leetcodemediumtreedepth-first-search
CF 49B - Sum

We are given two integers, _a_ and _b_, written in some unknown base _p_. Vasya wants to compute the sum _a + b_ in all valid bases and determine which base gives the sum with the largest number of digits.

codeforcescompetitive-programmingmath
LeetCode 509 - Fibonacci Number

This problem asks us to compute the nth Fibonacci number. The Fibonacci sequence is defined recursively. The first two numbers are fixed: Every value after that is calculated as the sum of the previous two values: Given an integer n, we must return the value of F(n).

leetcodeeasymathdynamic-programmingrecursionmemoization
LeetCode 437 - Path Sum III

The problem gives us the root of a binary tree and an integer targetSum. We need to count how many downward paths in the tree have values that add up exactly to targetSum. A path can begin at any node and end at any node, as long as it always moves downward from parent to child.

leetcodemediumtreedepth-first-searchbinary-tree
LeetCode 759 - Employee Free Time

The problem asks us to determine common free time intervals for a group of employees based on their schedules. Each employee has a list of non-overlapping intervals representing times when they are busy.

leetcodehardarraysweep-linesortingheap-(priority-queue)