brain
tamnd's digital brain — notes, problems, research
42768 notes
A clear explanation of designing a hash map without using built-in hash table libraries.
A clear explanation of hiring exactly k workers with minimum total cost using wage-to-quality ratios, sorting, and a max heap.
A greedy solution for increasing building heights as much as possible while preserving every skyline view.
Track the maximum number of overlapping calendar events using a sweep line difference map.
A clear explanation of designing a time-based key-value store using a hash map and binary search.
A clear explanation of solving Minimum Falling Path Sum using dynamic programming over matrix rows.
Find the earliest day when two turned-on bulbs have exactly k turned-off bulbs between them using a sliding window over bloom days.
A clear explanation of checking whether an array can become non-decreasing by modifying at most one element.
A dynamic programming and combinatorics solution for counting permutations with no fixed positions.
Simulate a baseball scoring system using a stack to process operations and compute the final score.
A clear explanation of minimizing rescue boats using sorting, greedy choice, and two pointers.
A clear explanation of finding the minimum possible number of rabbits using counting and greedy grouping.
A clear explanation of counting super-palindromes by generating palindromic roots and checking their squares.
A clear explanation of the Positions of Large Groups problem using a simple two-pointer scan.
A SQL guide for comparing each department's monthly average salary against the company's monthly average salary.
A two-pointer and number theory solution for checking whether an integer can be written as the sum of two square numbers.
A clear explanation of minimizing printer turns using interval dynamic programming.
A clear explanation of designing a hash set without using built-in hash table libraries.
A clear explanation of solving Pyramid Transition Matrix using backtracking and memoization over pyramid rows.
A clear explanation of scoring a balanced parentheses string using depth counting.
A simple simulation solution for counting how many 100-pixel lines are needed to write a string.
Allow double bookings but reject triple bookings using overlap interval tracking.
Find the next valid 24-hour time using only the digits from the current time.
A clear explanation of solving Binary Subarrays With Sum using prefix sums and a frequency map.
A clear explanation of finding the kth character in a decoded string without building the full decoded string.
A clear explanation of counting all paths from start to end that visit every non-obstacle square exactly once using backtracking.
A SQL guide for finding users who both follow someone and have followers, then counting how many followers they have.
A clear explanation of sorting an array by parity using a two-pointer partition method.
A clear explanation of checking whether a binary tree can be split into two equal-sum trees by removing one edge.
A clear explanation of checking whether one point can reach another by working backward with modulo.
A heap-based solution for finding the smallest range that contains at least one number from each sorted list.
A clear explanation of the Consecutive Numbers Sum problem using arithmetic series formulas and divisibility analysis.
A clear explanation of searching for a target in a sorted array using binary search.
A clear explanation of simulating water droplets over an elevation map by checking left first, then right.
A clear explanation of simulating an exam room by maintaining occupied seats in sorted order.
A dynamic programming solution for deciding whether an array can be split into two non-empty groups with the same average.
Count distinct non-empty palindromic subsequences using interval dynamic programming and duplicate handling.
Check whether a string can become a palindrome after deleting at most one character using two pointers.
A clear explanation of solving Unique Email Addresses using string normalization and a hash set.
A clear explanation of balancing coins in a binary tree using postorder DFS and subtree coin balance.
A clear explanation of counting profitable crime schemes using 0/1 knapsack dynamic programming with members and profit states.
A SQL guide for finding the minimum distance between any two unique points on the X-axis.
A clear explanation of finding the longest contiguous subarray with equal numbers of 0 and 1 using prefix sums and a hash map.
A clear explanation of deleting the minimum number of columns so rows become lexicographically sorted.
A clear explanation of checking whether an array can be reordered into pairs where one number is double the other.
A clear explanation of Fruit Into Baskets using a sliding window with at most two distinct fruit types.
A clear explanation of computing the maximum width of a binary tree using level-order traversal and complete-tree indices.
A clear explanation of finding the kth symbol in the grammar sequence using recursion and the parent-child relationship.
A clear explanation of finding the longest dictionary word obtainable as a subsequence using two pointers and sorting rules.
A SQL guide for finding the minimum Euclidean distance between any two points in a 2D plane.
A design solution for a small Excel-like spreadsheet that supports set, get, and dynamic sum formulas.
A clear digit dynamic programming solution for counting numbers whose binary representation does not contain consecutive ones.
A set-based solution for counting how many different Morse code transformations appear among a list of words.
A clear explanation of finding the minimum number of swaps needed to transform one anagram string into another using BFS.
A clear explanation of reaching a target on a number line using cumulative sums and parity.
Implement a calendar that accepts a booking only when it does not overlap with any existing booking.
A clear explanation of maintaining the kth largest element in a stream using a fixed-size min heap.
Determine whether four numbers can be combined with arithmetic operations and parentheses to produce 24.
A clear explanation of solving Minimize Malware Spread II by removing each infected node and simulating the final malware spread.
A clear explanation of finding the longest subarray whose adjacent comparisons alternate between greater-than and less-than.
A clear explanation of finding the nth magical number using binary search, greatest common divisor, least common multiple, and inclusion-exclusion.
A clear explanation of Count Unique Characters of All Substrings using contribution counting with previous and next occurrences.
A clear explanation of checking whether words are sorted according to a custom alien alphabet order.
A clear explanation of counting valid DI permutations using dynamic programming and prefix sums.
A clear explanation of averaging neighboring pixels in a matrix using direct simulation.
A clear explanation of Distribute Candies using a set to count candy types and a simple limit argument.
A clear explanation of finding the nth positive integer that does not contain the digit 9 using base-9 conversion.
A clear explanation of detecting a subarray whose sum is a multiple of k using prefix sums and modular arithmetic.
A clear explanation of finding the minimum time to reach the bottom-right cell using a priority queue and minimax path reasoning.
A two-pointer guide for counting triplets that can form valid triangles after sorting the side lengths.
A clear explanation of deciding whether a sorted array can be split into consecutive subsequences of length at least three.
A SQL guide for checking whether three side lengths can form a valid triangle using the triangle inequality.
A clear explanation of calculating the fraction of players who logged in again the day after their first login.
A clear hash map solution for finding common strings with the smallest index sum.
A clear explanation of finding the k closest elements to a target using binary search and a sliding window.
A hash map guide for grouping file paths by identical file content and returning only duplicate groups.
A clear explanation of finding the longest increasing or decreasing consecutive path in a binary tree using DFS.
A SQL guide for classifying binary tree nodes as Root, Inner, or Leaf based on parent-child relationships.
A clear explanation of determining whether a robot returns to the origin after executing movement instructions.
A clear math solution for counting the maximum values after repeated top-left matrix increment operations.
A clear explanation of Winning Candidate using SQL aggregation to count votes and return the candidate with the most votes.
A clear explanation of splitting an array into four equal-sum parts using prefix sums and set-based search.
A clear explanation of finding the longest uncommon subsequence among many strings using subsequence checks.
A clear explanation of finding the longest uncommon subsequence between two strings using simple case analysis.
A SQL guide for finding salespeople who never had an order related to the company named RED.
A greedy heap solution for taking the maximum number of courses before their deadlines.
A clear explanation of finding the minimum-cost path with bounded jumps, blocked cells, and lexicographic tie-breaking.
A recursive guide for converting a binary tree into a preorder parenthesized string while preserving the one-to-one mapping between the tree and the string.
A clear explanation of counting connected components in an undirected graph represented by an adjacency matrix.
A clear SQL guide for computing the overall friend request acceptance rate with duplicate pairs counted once.
A clear explanation of Squirrel Simulation using Manhattan distance and the special first trip.
A clear explanation of checking whether a word uses capital letters correctly by counting uppercase letters.
A clear explanation of Subtree of Another Tree using recursive tree matching and DFS.
A clear explanation of randomly flipping zero cells in a matrix without repetition using hash mapping and virtual swapping.
A clear SQL guide for finding classes that have at least five students.
A clear explanation of Find Median Given Frequency of Numbers using cumulative frequency and SQL window functions.
A clear explanation of counting coin-change combinations using dynamic programming.
A clear explanation of maximizing remove-box scores using interval dynamic programming with memoization.
A clear explanation of Managers with at Least 5 Direct Reports using grouping and a self join.
A clear explanation of collecting the boundary of a binary tree using separate left boundary, leaves, and right boundary traversals.