brain
tamnd's digital brain — notes, problems, research
43815 notes
A clear explanation of inserting a value into a sorted circular linked list while preserving the circular sorted order.
A two-pointer group comparison solution for counting how many words can be stretched to match a target string.
A clear explanation of checking whether one swap in a string can make it equal to another string.
A clear explanation of finding common free time by merging all employee busy intervals and returning the gaps.
Check whether two word arrays are sentence-similar using a hash set of symmetric similar word pairs.
A clear explanation of computing the projection areas of stacked cubes from top, front, and side views.
A clear explanation of solving Number of Recent Calls using a queue as a sliding time window.
A clear explanation of finding the cheapest way to cover all travel days using dynamic programming.
A clear explanation of minimizing an array score after each value can move by at most k.
A clear explanation of solving Tallest Billboard using dynamic programming over height differences.
A clear explanation of finding the minimum difference between any two nodes in a BST using inorder traversal.
A clear explanation of the Flipping an Image problem using row reversal, bit inversion, and an in-place two-pointer method.
Find three non-overlapping subarrays of length k with maximum total sum and return the lexicographically smallest starting indices.
A clear explanation of maximizing an integer by swapping at most two digits once.
An array-based circular buffer solution for implementing a fixed-size double-ended queue.
A string parsing solution for reducing a linear equation into coefficient and constant terms.
A clear explanation of trimming a BST so that all remaining node values lie inside a given inclusive range.
Compute the probability that a knight remains on an n x n chessboard after exactly k random moves using dynamic programming.
A dynamic programming solution for counting decodings of a digit string with wildcard characters.
Find the longest path in a binary tree where every node on the path has the same value using depth-first search.
A SQL guide for filtering movies with odd IDs and non-boring descriptions, then sorting by rating.
A clear explanation of implementing a linked list from scratch using nodes, a dummy head, and a size counter.
A clear explanation of marking matching substrings and merging overlapping bold ranges.
A clear explanation of Mirror Reflection using room unfolding, least common multiples, and parity.
A probability dynamic programming solution for computing whether soup A empties before soup B, with an early return for large input.
A clear explanation of solving Beautiful Array using divide and conquer with odd and even transformations.
Recolor the connected component containing the starting pixel using depth-first search.
A clear explanation of counting ordered triples whose bitwise AND is zero using pairwise AND counts.
A clear explanation of finding the kth smallest value in an m by n multiplication table using binary search on answer.
A DFS and memoization solution for finding the minimum cost to satisfy item needs using individual prices and reusable special offers.
A SQL guide for finding the largest number that appears exactly once in a table.
Find the minimum number of times one string must be repeated so another string becomes a substring.
Find the directed edge to remove so a graph becomes a rooted tree again, handling both cycles and nodes with two parents.
A breadth-first search solution for computing the average value of nodes at each level of a binary tree.
A clear explanation of constructing an array with exactly k distinct adjacent differences using a greedy pattern.
A SQL guide for pivoting rows into columns using ranking and conditional aggregation.
A stack-based solution for computing exclusive execution time from nested start and end logs.
A recursive tree traversal guide for merging two binary trees node by node.
A clear explanation of counting reachable original and subdivided nodes using Dijkstra's shortest path algorithm.
A clear explanation of summing subarray minimums using a monotonic stack and contribution counting.
A clear explanation of transforming a binary board into a chessboard using feasibility checks and minimum row and column swaps.
A clear explanation of the Masking Personal Information problem using string parsing and format-specific masking rules.
Find the extra edge in an undirected graph that creates a cycle using Union-Find.
A clear explanation of computing all root-to-leaf path sums from a compact three-digit binary tree encoding.
A string-marking guide for adding bold tags around all matched words while merging overlapping and adjacent bold regions.
A design solution for storing timestamped logs and retrieving IDs by inclusive time range at a chosen granularity.
A clear explanation of solving interval intersection constraints using greedy sorting and minimal point selection.
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.