brain

tamnd's digital brain — notes, problems, research

42695 notes

LeetCode 1248 - Count Number of Nice Subarrays

The problem asks us to count how many contiguous subarrays contain exactly k odd numbers. We are given an integer array

leetcodemediumarrayhash-tablemathsliding-windowprefix-sum
CF 86A - Reflection

We are given two integers, l and r. For every number n inside this interval, we build another number called its reflection. The reflection is created digit by digit. Every decimal digit d becomes 9 - d.

codeforcescompetitive-programmingmath
CF 8A - Train and Peter

We are given a string that represents the sequence of station flags seen while traveling from city A to city B. Peter woke up twice during the trip and wrote down two substrings he saw, in chronological order.

codeforcescompetitive-programmingstrings
CF 108B - Datatypes

We are given several unsigned integer datatypes, each defined by its bit length. A datatype with a bits can store every integer from 0 up to 2^a - 1. We want to know whether there exists some integer x and two datatypes with sizes a[i] < a[j] such that: 1.

codeforcescompetitive-programmingmathsortings
LeetCode 1195 - Fizz Buzz Multithreaded

The problem asks us to coordinate four separate threads so they collectively print the correct Fizz Buzz sequence in order from 1 to n. Unlike the classic single threaded Fizz Buzz problem, this version introduces concurrency.

leetcodemediumconcurrency
LeetCode 351 - Android Unlock Patterns

The problem models the Android lock screen as a 3 x 3 grid containing digits 1 through 9. A valid unlock pattern is a sequence of distinct dots that follows a special movement rule. The first rule is straightforward: each dot can only be used once in a pattern.

leetcodemediumdynamic-programmingbacktrackingbit-manipulationbitmask
LeetCode 604 - Design Compressed String Iterator

This problem asks us to implement a compressed string iterator. We are given a string where each character is immediately followed by a number representing how many times that character appears consecutively in the uncompressed version. For example, "a3b2" represents "aaabb".

leetcodeeasyarraystringdesigniterator
LeetCode 1755 - Closest Subsequence Sum

The problem asks us to find a subsequence of a given integer array nums such that the sum of that subsequence is as close as possible to a given integer goal.

leetcodehardarraytwo-pointersdynamic-programmingbit-manipulationsortingbitmask
LeetCode 1283 - Find the Smallest Divisor Given a Threshold

The problem asks us to find the smallest positive integer divisor for a given array nums such that when each element of

leetcodemediumarraybinary-search
LeetCode 641 - Design Circular Deque

The problem asks us to design a circular double-ended queue, also called a deque. A deque is a data structure that allows insertion and deletion from both the front and the rear.

leetcodemediumarraylinked-listdesignqueue
LeetCode 1234 - Replace the Substring for Balanced String

The problem asks us to balance a string composed of exactly four types of characters: 'Q', 'W', 'E', and 'R'. A string is balanced when each character occurs exactly n / 4 times, where n is the length of the string.

leetcodemediumstringsliding-window
LeetCode 1214 - Two Sum BSTs

The problem gives us two binary search trees, root1 and root2, along with an integer target. We must determine whether there exists one node from the first tree and one node from the second tree such that their values add up exactly to target.

leetcodemediumtwo-pointersbinary-searchstacktreedepth-first-searchbinary-search-treebinary-tree
LeetCode 801 - Minimum Swaps To Make Sequences Increasing

The problem gives us two arrays, nums1 and nums2, both of the same length. At every index i, we are allowed to either keep the values as they are, or swap nums1[i] with nums2[i]. Our goal is to make both arrays strictly increasing while performing the minimum number of swaps.

leetcodehardarraydynamic-programming
LeetCode 507 - Perfect Number

This problem asks us to determine whether a given positive integer num is a perfect number. A perfect number is defined as a number whose sum of positive divisors, excluding the number itself, equals the number.

leetcodeeasymath
LeetCode 1123 - Lowest Common Ancestor of Deepest Leaves

This problem asks us to find the lowest common ancestor, abbreviated as LCA, of all the deepest leaf nodes in a binary tree. A leaf node is any node with no children. The depth of the root is 0, and every level downward increases the depth by 1.

leetcodemediumhash-tabletreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 1257 - Smallest Common Region

This problem describes a hierarchical relationship between geographic regions. Each list in regions represents a parent-child relationship where the first element is the parent region and every remaining element in the list is directly contained within that parent.

leetcodemediumarrayhash-tablestringtreedepth-first-searchbreadth-first-search
LeetCode 1438 - Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit

The problem asks us to find the length of the longest contiguous subarray in an integer array nums such that the absolut

leetcodemediumarrayqueuesliding-windowheap-(priority-queue)ordered-setmonotonic-queue
LeetCode 827 - Making A Large Island

This problem asks us to find the largest possible island size in a binary grid after changing at most one 0 into 1.

leetcodehardarraydepth-first-searchbreadth-first-searchunion-findmatrix
LeetCode 1021 - Remove Outermost Parentheses

Unusual activity has been detected from your device. Try again later. (36c3723c-3fa3-4b63-a514-20d2635d5e47)

leetcodeeasystringstack
CF 53D - Physical Education

We have two arrays representing the order of students in a line. Array a is the desired arrangement, and array b is the current arrangement. In one operation we may swap two neighboring students. We must output any sequence of adjacent swaps that transforms b into a.

codeforcescompetitive-programmingsortings
LeetCode 88 - Merge Sorted Array

This problem gives us two arrays, nums1 and nums2, where both arrays are already sorted in non-decreasing order. We are also given two integers, m and n, which tell us how many valid elements exist in each array. The important detail is that nums1 has extra space at the end.

leetcodeeasyarraytwo-pointerssorting
LeetCode 863 - All Nodes Distance K in Binary Tree

This problem gives us the root of a binary tree, a specific target node inside that tree, and an integer k. Our task is to return all node values whose distance from the target node is exactly k. The important detail is the definition of distance.

leetcodemediumhash-tabletreedepth-first-searchbreadth-first-searchbinary-tree
CF 22C - System Administrator

We are asked to design a network of servers where each server is a node, and each connection between two servers is an undirected edge. There are n servers and we are allowed exactly m connections.

codeforcescompetitive-programminggraphs
LeetCode 826 - Most Profit Assigning Work

This problem asks us to maximize the total profit earned by assigning jobs to workers, under a specific rule: each worker can only perform jobs whose difficulty is less than or equal to their ability.

leetcodemediumarraytwo-pointersbinary-searchgreedysorting
LeetCode 1754 - Largest Merge Of Two Strings

This problem asks us to build the lexicographically largest possible string by repeatedly choosing characters from the front of two given strings.

leetcodemediumtwo-pointersstringgreedy
LeetCode 225 - Implement Stack using Queues

The problem asks us to implement a stack data structure while using only queue operations internally. A stack follows the Last-In-First-Out, or LIFO, principle. This means the most recently inserted element must be removed first.

leetcodeeasystackdesignqueue
CF 60D - Savior

Each lawn contains a distinct positive integer. Two lawns are considered connected if their numbers can appear together in some primitive Pythagorean triple.

codeforcescompetitive-programmingbrute-forcedsumath
LeetCode 857 - Minimum Cost to Hire K Workers

In this problem, we are given two arrays, quality and wage, where each index represents a worker. The value quality[i] describes how much work or contribution the i-th worker provides, while wage[i] describes the minimum amount that worker is willing to accept.

leetcodehardarraygreedysortingheap-(priority-queue)
CF 120G - Boom

We are simulating a simplified version of the party game "Boom" with multiple teams and cards. There are n teams, each with two players. Each player has an ability to explain words (a) and an ability to understand words (b).

codeforcescompetitive-programmingimplementation
CF 1941F - Rudolf and Imbalance

We start with a strictly increasing array of problem complexities. The imbalance of the set is defined as the largest difference between two neighboring elements after sorting.

codeforcescompetitive-programmingbinary-searchgreedysortingstwo-pointers
LeetCode 986 - Interval List Intersections

The problem gives us two lists of closed intervals. Each interval is represented as [start, end], meaning every value from start through end, inclusive, belongs to that interval.

leetcodemediumarraytwo-pointerssweep-line
LeetCode 792 - Number of Matching Subsequences

The problem asks us to count how many words in a given list are subsequences of a string s. A subsequence is formed by deleting zero or more characters from the string without changing the order of the remaining characters.

leetcodemediumarrayhash-tablestringbinary-searchdynamic-programmingtriesorting
LeetCode 813 - Largest Sum of Averages

The problem gives us an integer array nums and an integer k. We are allowed to split the array into at most k contiguous, non-empty subarrays. For each subarray, we compute its average, then sum all of those averages together. Our goal is to maximize that total score.

leetcodemediumarraydynamic-programmingprefix-sum
CF 89C - Chip Play

We have a grid containing chips. Every chip stores one direction, left, right, up, or down. When we start a move from some chip, the process behaves like this: The current chip looks in the direction of its arrow.

codeforcescompetitive-programmingbrute-forcedata-structuresimplementation
LeetCode 1281 - Subtract the Product and Sum of Digits of an Integer

The problem asks us to compute a simple mathematical transformation on the digits of an integer. Given an integer n, we

leetcodeeasymath
LeetCode 349 - Intersection of Two Arrays

The problem gives us two integer arrays, nums1 and nums2, and asks us to return their intersection. The intersection consists of all values that appear in both arrays. However, the result must contain only unique elements, even if a number appears many times in either array.

leetcodeeasyarrayhash-tabletwo-pointersbinary-searchsorting
LeetCode 847 - Shortest Path Visiting All Nodes

The problem gives us an undirected and connected graph with n nodes labeled from 0 to n - 1. The graph is represented as an adjacency list, where graph[i] contains all nodes directly connected to node i.

leetcodeharddynamic-programmingbit-manipulationbreadth-first-searchgraph-theorybitmask
LeetCode 96 - Unique Binary Search Trees

This problem asks us to determine how many structurally different Binary Search Trees, or BSTs, can be formed using the integers from 1 to n. A Binary Search Tree has an important property: - Every value in the left subtree is smaller than the root.

leetcodemediummathdynamic-programmingtreebinary-search-treebinary-tree
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
CF 88A - Chord

We are given three musical notes, and the task is to classify the chord they form as either major, minor, or "strange". Notes are represented in the twelve-tone chromatic scale: C, C, D, D, E, F, F, G, G, A, B, H, and the scale is cyclic, so after H comes C again.

codeforcescompetitive-programmingbrute-forceimplementation
CF 94B - Friends

We have exactly five people. Some pairs of people know each other, and the input lists all such acquaintance relations. The task is to determine whether there exists either: 1. Three people where every pair knows each other. 2. Three people where no pair knows each other.

codeforcescompetitive-programminggraphsimplementationmath
LeetCode 1227 - Airplane Seat Assignment Probability

This problem involves a scenario with n passengers and n seats on an airplane. Each passenger has a designated seat, but the first passenger has lost their ticket and picks a seat randomly.

leetcodemediummathdynamic-programmingbrainteaserprobability-and-statistics
LeetCode 482 - License Key Formatting

The problem gives us a string s that represents a license key. The string contains uppercase letters, lowercase letters, digits, and dashes. The existing dashes are only separators and do not necessarily represent the correct final grouping.

leetcodeeasystring
LeetCode 2002 - Maximum Product of the Length of Two Palindromic Subsequences

The problem is asking us to find two disjoint palindromic subsequences from a given string s such that the product of their lengths is maximized. A subsequence is derived by deleting zero or more characters from the original string while keeping the relative order intact.

leetcodemediumstringdynamic-programmingbacktrackingbit-manipulationbitmask
LeetCode 2027 - Minimum Moves to Convert String

The problem asks us to transform a string s containing only characters 'X' and 'O' so that all characters become 'O'. A move consists of selecting three consecutive characters and converting them to 'O'. If a character is already 'O', it remains unchanged.

leetcodeeasystringgreedy
LeetCode 1516 - Move Sub-Tree of N-Ary Tree

This problem asks us to modify the structure of an N-ary tree by moving one subtree under another node. Every node contains a unique value, and each node may have any number of children.

leetcodehardtreedepth-first-search
LeetCode 937 - Reorder Data in Log Files

In this problem, we are given a list of log strings. Each log contains an identifier followed by one or more words separated by spaces. The first token is always the identifier, and everything after it represents the content of the log.

leetcodemediumarraystringsorting
LeetCode 855 - Exam Room

This problem requires designing a simulation for an exam room seating arrangement. We have n seats in a single row, labeled from 0 to n - 1. Students enter one by one, and each student chooses a seat such that the distance to the closest occupied seat is maximized.

leetcodemediumdesignheap-(priority-queue)ordered-set
CF 116A - Tram

We have a single tram traveling along a line with n stops, starting empty at the first stop and ending empty at the last stop. At each stop, a certain number of passengers exit before any new passengers enter.

codeforcescompetitive-programmingimplementation
LeetCode 1762 - Buildings With an Ocean View

This problem gives us an array called heights, where each element represents the height of a building. The buildings are arranged in a straight line from left to right, and the ocean is located to the right side of the last building.

leetcodemediumarraystackmonotonic-stack
CF 42D - Strange town

We are asked to construct a fully connected graph of _N_ tourist attractions, where each road has a distinct positive integer cost not exceeding 1000.

codeforcescompetitive-programmingconstructive-algorithmsmath
LeetCode 73 - Set Matrix Zeroes

The problem gives us a two dimensional matrix of integers with m rows and n columns. We must modify the matrix in place so that whenever a cell contains 0, every element in that cell's entire row and entire column also becomes 0.

leetcodemediumarrayhash-tablematrix
CF 84A - Toy Army

We have two armies, each containing n soldiers. The value of n is always even. The game lasts exactly three turns: 1. Valera attacks Arcady. 2. Arcady attacks Valera. 3. Valera attacks Arcady again.

codeforcescompetitive-programmingmathnumber-theory
LeetCode 934 - Shortest Bridge

The problem gives us an n x n binary matrix called grid. Each cell contains either 1 or 0. A value of 1 represents land, and a value of 0 represents water. Land cells that are connected vertically or horizontally form an island.

leetcodemediumarraydepth-first-searchbreadth-first-searchmatrix
LeetCode 1678 - Goal Parser Interpretation

This problem asks us to interpret a Goal Parser command string. The string command consists of the characters "G", "()",

leetcodeeasystring
LeetCode 1740 - Find Distance in a Binary Tree

This problem asks us to determine the distance between two nodes in a binary tree, given their values p and q. The distance is defined as the number of edges in the shortest path connecting the two nodes.

leetcodemediumhash-tabletreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 546 - Remove Boxes

The problem gives us an array called boxes, where each integer represents the color of a box. We may repeatedly remove groups of adjacent boxes that share the same color. If we remove a group containing k boxes, we earn k k points.

leetcodehardarraydynamic-programmingmemoization
CF 128B - String

We are given a string of lowercase letters and an integer k. The task is to generate all possible substrings of the string, sort them lexicographically, and return the k-th substring in that order.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmshashingimplementationstring-suffix-structuresstrings
LeetCode 1125 - Smallest Sufficient Team

This problem asks us to build the smallest possible team that collectively covers every required skill. We are given two inputs: - reqskills, a list of unique required skills - people, where people[i] contains the skills possessed by person i A team is considered sufficient if…

leetcodehardarraydynamic-programmingbit-manipulationbitmask
LeetCode 901 - Online Stock Span

The problem asks us to design a class that processes stock prices one day at a time and, for every new price, returns the stock span for that day.

leetcodemediumstackdesignmonotonic-stackdata-stream
CF 33A - What is for dinner?

Each tooth belongs to exactly one row. When Valerie eats one crucian using a row, every tooth in that row loses one unit of viability. A row becomes unusable as soon as at least one tooth inside it would drop below zero.

codeforcescompetitive-programminggreedyimplementation
LeetCode 1674 - Minimum Moves to Make Array Complementary

The problem requires us to transform an array nums of even length n into a complementary array. An array is complementar

leetcodemediumarrayhash-tableprefix-sum
LeetCode 258 - Add Digits

The problem asks us to repeatedly transform a number by summing its digits until only a single digit remains. The final single digit should then be returned. For example, if the input is 38, we first compute 3 + 8 = 11.

leetcodeeasymathsimulationnumber-theory
LeetCode 1608 - Special Array With X Elements Greater Than or Equal X

The problem gives us an array nums containing non-negative integers. We need to determine whether there exists an intege

leetcodeeasyarraybinary-searchsorting
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 1131 - Maximum of Absolute Value Expression

The problem gives us two integer arrays, arr1 and arr2, both having the same length. We must compute the maximum possible value of the following expression across every pair of indices (i, j): The task is not asking for the indices themselves, only the largest achievable value.

leetcodemediumarraymath
LeetCode 588 - Design In-Memory File System

The problem asks us to design an in-memory file system that simulates basic file system operations without interacting with the real filesystem.

leetcodehardhash-tablestringdesigntriesorting
LeetCode 177 - Nth Highest Salary

This problem asks us to write a SQL function that returns the nth highest distinct salary from the Employee table. The table contains two columns: Column Meaning --- --- id Unique employee identifier salary Employee salary The key detail is that the salary must be distinct.

leetcodemediumdatabase
LeetCode 319 - Bulb Switcher

The problem describes a sequence of n bulbs, all initially turned off. We perform n rounds of operations on these bulbs. In the first round, every bulb is turned on. In the second round, every second bulb is toggled, meaning on bulbs become off and off bulbs become on.

leetcodemediummathbrainteaser
LeetCode 2017 - Grid Game

The problem gives us a 2 x n grid where each cell contains some number of points. Two robots move across this grid one after another. Both robots start at the top-left corner (0, 0) and must reach the bottom-right corner (1, n - 1). The movement rules are very restrictive.

leetcodemediumarraymatrixprefix-sum
LeetCode 311 - Sparse Matrix Multiplication

This problem asks us to multiply two matrices, but with an important detail: both matrices are sparse. A sparse matrix is a matrix where most entries are zero. The goal is to take advantage of this property so that we avoid unnecessary computation involving zero values.

leetcodemediumarrayhash-tablematrix
LeetCode 496 - Next Greater Element I

The problem is asking us to find the next greater element for each element in nums1 within another array nums2. Formally, for each element in nums1, we need to locate its position in nums2 and then find the first element to its right in nums2 that is greater than itself.

leetcodeeasyarrayhash-tablestackmonotonic-stack
CF 128D - Numbers

We are given a multiset of numbers and asked whether it is possible to arrange them in a circle so that every pair of adjacent numbers differs by exactly one. Conceptually, this means each number is a vertex on a cycle, and the absolute difference between neighbors must be 1.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
LeetCode 603 - Consecutive Available Seats

The problem gives us a database table named Cinema with two columns: Column Meaning --- --- seatid Unique identifier for a seat free Whether the seat is available, where 1 means free and 0 means occupied We need to find all seats that are part of at least one consecutive…

leetcodeeasydatabase
LeetCode 1400 - Construct K Palindrome Strings

The problem is asking whether a given string s can be rearranged to form exactly k non-empty palindrome strings using al

leetcodemediumhash-tablestringgreedycounting
LeetCode 1366 - Rank Teams by Votes

The problem describes a voting based ranking system where every voter ranks all teams from best to worst. Each vote is r

leetcodemediumarrayhash-tablestringsortingcounting
LeetCode 1472 - Design Browser History

The problem is asking us to simulate a single-tab browser with a history mechanism. You start on a homepage, and from there, you can visit new URLs, backtrack a certain number of steps, or forward a certain number of steps.

leetcodemediumarraylinked-liststackdesigndoubly-linked-listdata-stream
CF 114A - Cifera

We are given two integers, k and l. The task is to determine whether l can be written as an exact power of k. In other words, we need to check whether there exists a non-negative integer n such that: $l = k^n$ If such an n exists, we print "YES" and also print the importance…

codeforcescompetitive-programmingmath
LeetCode 1583 - Count Unhappy Friends

In this problem, we are given n friends, where n is always even. Every friend ranks all other friends in order of preference. The earlier someone appears in a person's preference list, the more that person is preferred. We are also given a final pairing arrangement.

leetcodemediumarraysimulation
LeetCode 888 - Fair Candy Swap

The problem gives us two arrays, aliceSizes and bobSizes, representing the candy boxes owned by Alice and Bob. Each element in the arrays is the number of candies in a particular box.

leetcodeeasyarrayhash-tablebinary-searchsorting
CF 97B - Superset

We start with a set of distinct lattice points on the plane. We may add more points, and the final set must satisfy a geometric condition for every pair of points. Take any two points.

codeforcescompetitive-programmingconstructive-algorithmsdivide-and-conquer
LeetCode 769 - Max Chunks To Make Sorted

This problem is asking us to determine the maximum number of contiguous chunks into which we can split an array such that sorting each chunk individually and concatenating them results in a fully sorted array.

leetcodemediumarraystackgreedysortingmonotonic-stack
CF 17D - Notepad

Nick wants to list all numbers of a given length n in base b, where digits range from 0 to b-1, but numbers cannot start with 0. Each page in his notepad holds exactly c numbers. We are asked to compute how many numbers appear on the last page he fills.

codeforcescompetitive-programmingnumber-theory
LeetCode 597 - Friend Requests I: Overall Acceptance Rate

This problem asks us to compute the overall acceptance rate of friend requests in a social network system. Two database tables are provided. The first table, FriendRequest, stores all friend requests that users sent to each other.

leetcodeeasydatabase
LeetCode 1167 - Minimum Cost to Connect Sticks

The problem gives us an array of positive integers called sticks, where each value represents the length of a stick. We are allowed to repeatedly connect any two sticks together.

leetcodemediumarraygreedyheap-(priority-queue)
CF 107E - Darts

We have several rectangles on the plane. Each rectangle represents a photo hanging on a wall. The rectangles may overlap, may share edges, may coincide completely, and may also be rotated arbitrarily.

codeforcescompetitive-programminggeometryprobabilities
LeetCode 605 - Can Place Flowers

The problem gives us a binary array called flowerbed, where: - 0 represents an empty plot - 1 represents a plot that already contains a flower We are also given an integer n, which represents how many new flowers we want to plant.

leetcodeeasyarraygreedy
LeetCode 1305 - All Elements in Two Binary Search Trees

The problem gives us two binary search trees, root1 and root2. A binary search tree, commonly abbreviated as BST, has the important property that for every node: - All values in the left subtree are smaller than the node's value - All values in the right subtree are larger…

leetcodemediumtreedepth-first-searchbinary-search-treesortingbinary-tree
LeetCode 1476 - Subrectangle Queries

The problem asks us to design a class called SubrectangleQueries that operates on a two dimensional integer matrix, refe

leetcodemediumarraydesignmatrix
CF 76C - Mutation

We are given a string representing the genome of an organism, where each character is one of the first K capital letters. Adjacent genes contribute to the total “risk of disease” according to a given K × K matrix of non-negative integers.

codeforcescompetitive-programmingbitmasksdpmath
LeetCode 1429 - First Unique Number

The problem requires designing a data structure that can efficiently maintain and retrieve the first unique integer in a

leetcodemediumarrayhash-tabledesignqueuedata-stream
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
CF 81B - Sequence Formatting

We are given a messy textual representation of a sequence. The string may contain positive integers, commas, spaces, and the special token .... Spaces may appear in the wrong places or appear multiple times. The task is purely formatting.

codeforcescompetitive-programmingimplementationstrings
LeetCode 2067 - Number of Equal Count Substrings

The problem asks us to count the number of substrings in a string s such that every unique character in the substring occurs exactly count times. A substring is a contiguous segment of the string, so we are only considering consecutive characters.

leetcodemediumhash-tablestringsliding-windowcounting
LeetCode 582 - Kill Process

This problem models processes in an operating system as a tree structure. Every process has exactly one parent, except for the root process, which has no parent and is identified by ppid[i] = 0.

leetcodemediumarrayhash-tabletreedepth-first-searchbreadth-first-search
LeetCode 1469 - Find All The Lonely Nodes

This problem asks us to traverse a binary tree and identify every node that is considered "lonely". A node is lonely if

leetcodeeasytreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 1660 - Correct a Binary Tree

Here is a complete, detailed technical solution guide for LeetCode 1660 - Correct a Binary Tree, formatted exactly as re

leetcodemediumhash-tabletreedepth-first-searchbreadth-first-searchbinary-tree
LeetCode 153 - Find Minimum in Rotated Sorted Array

This problem asks us to find the smallest element in a sorted array that has been rotated some number of times. A sorted array in ascending order might originally look like this: After rotation, it could become: or remain unchanged: The important observation is that the array…

leetcodemediumarraybinary-search
LeetCode 1797 - Design Authentication Manager

The problem asks us to design an authentication system that manages tokens with expiration times. Each token is valid for a fixed timeToLive seconds starting from the moment it is generated or renewed.

leetcodemediumhash-tablelinked-listdesigndoubly-linked-list
LeetCode 41 - First Missing Positive

The problem asks us to find the smallest positive integer that does not appear in an unsorted integer array. The key detail is that we only care about positive integers starting from 1.

leetcodehardarrayhash-table