brain
tamnd's digital brain — notes, problems, research
43815 notes
A clear explanation of finding universal words by merging character frequency requirements from words2.
A clear explanation of finding the closest shorthand RGB color by rounding each color channel to the nearest repeated hexadecimal pair.
A clear explanation of checking whether every global inversion is also a local inversion using distance constraints.
A clear explanation of splitting a linked list into k consecutive parts with sizes as equal as possible.
A clear explanation of making all bits equal to 1 using greedy left-to-right flips and a sliding window flip parity.
A suffix-removal solution for finding the shortest reference string that can encode every word.
A clear explanation of maximizing the advantage of one array over another using sorting, greedy matching, and two pointers.
A clear explanation of the Similar String Groups problem using graph connectivity and union-find.
A clear explanation of finding the minimum-area rectangle from points when the rectangle may be rotated.
A clear explanation of finding the smallest left partition using prefix maximums and suffix minimums.
A clear explanation of generating all full binary trees with n nodes using recursion and memoization.
A clear explanation of solving Minimum Increment to Make Array Unique by sorting and greedily assigning the next available value.
A clear explanation of simulating overflow in a champagne glass pyramid using dynamic programming.
A clear explanation of solving Delete Columns to Make Sorted by checking each column independently.
A clear explanation of finding the smallest rotation with maximum score using a difference array.
A clear explanation of minimizing the largest adjacent gas-station distance using binary search on the answer.
A clear explanation of finding the leftmost pivot index using prefix sums and a running left sum.
A clear explanation of finding the minimum time for all oranges to rot using multi-source BFS.
A clear explanation of checking whether two binary tree nodes are cousins using BFS with parent tracking.
A hash map and string parsing solution for finding the most frequent non-banned word in a paragraph.
A clear explanation of solving the 2 x 3 sliding puzzle using breadth-first search over board states.
A clear explanation of restoring a Candy Crush board to a stable state using repeated marking, crushing, and gravity simulation.
A clear explanation of finding every path from node 0 to node n - 1 in a directed acyclic graph using DFS and backtracking.
A clear explanation of checking whether the digits of a number can be reordered to form a power of two using digit frequency signatures.
A clear explanation of counting subarrays with exactly k distinct integers using the at-most-k sliding window trick.
A clear explanation of counting special-equivalent string groups by building canonical signatures from even and odd positions.
Count axis-aligned rectangles whose four corners are 1 using column-pair frequency counting.
A dynamic programming solution for finding the shortest instruction sequence that drives a race car to the target position.
A clear explanation of solving Find the Shortest Superstring using pairwise overlaps and bitmask dynamic programming.
A clear explanation of checking whether one string can become another by repeated left rotations.
A clear explanation of evaluating arithmetic expressions with parentheses, precedence, and integer division.
A clear explanation of removing line comments and block comments from source code using a state machine.
A clear explanation of finding the maximum distance between adjacent set bits in a binary representation.
A clear explanation of finding the minimum operations by working backward from target to startValue.
A clear explanation of computing the exposed surface area of stacked cubes by adding tower area and subtracting shared faces.
Simulate virus containment by repeatedly quarantining the most dangerous infected region and spreading the remaining regions.
A clear explanation of solving DI String Match using a greedy two-pointer construction.
A hash set and linked list traversal solution for counting consecutive components whose values appear in nums.
A clear explanation of transposing a matrix by swapping row and column indices.
A clear explanation of counting how many stones are jewels using a hash set for fast membership checks.
A clear explanation of counting contiguous subarrays whose maximum value lies inside a given inclusive range.
A clear explanation of merging accounts that share emails using union find and sorted email groups.
A clear explanation of Pow(x, n) using binary exponentiation to compute powers in logarithmic time.
Find the shortest word that contains all required license plate letters using frequency counting.
A clear explanation of summing subsequence widths by sorting and counting each element as a maximum and minimum.
A clear explanation of solving Valid Mountain Array by walking up the increasing slope and then down the decreasing slope.
A clear explanation of checking equality and inequality constraints using union-find.
A clear explanation of finding the smallest prime palindrome greater than or equal to n by generating odd-length palindromes and testing primality.
An enumeration solution for reconstructing all valid coordinate pairs after commas, spaces, and decimal points were removed.
A clear explanation of counting uni-value subtrees using post-order DFS.
A clear explanation of the Rising Temperature SQL problem using a self join and date comparison.
A clear explanation of simplifying algebraic expressions by parsing, substituting variables, and combining polynomial terms.
A clear explanation of finding the longest buildable word using sorting and a hash set.
Find whether the maximum element is at least twice every other element using a single linear scan.
A clear explanation of validating whether a Tic-Tac-Toe board can occur in a legal game.
A clear explanation of Group Anagrams using a hash map keyed by each word's sorted character signature.
A clear explanation of finding words that match a pattern using bijective character mapping.
A clear explanation of solving Distinct Subsequences II using dynamic programming and last occurrence tracking.
A clear explanation of splitting a permutation into the maximum number of chunks using prefix maximums.
A clear explanation of finding how many integers have exactly k trailing zeroes in their factorial.
Find the minimum cost to reach the top of the staircase using dynamic programming.
A clear explanation of finding the kth smallest pair distance using sorting, binary search on the answer, and a two-pointer count.
A clear explanation of grouping strings by their shifting sequence using normalized hash keys.
A clear explanation of the Delete Duplicate Emails SQL problem using DELETE with a self join.
A clear explanation of Rotate Image using in-place matrix transpose and row reversal.
A clear explanation of counting strobogrammatic numbers in a string range using recursive generation and range filtering.
A clear explanation of generating all strobogrammatic numbers of length n using recursion from the inside out.
A clear explanation of Permutations II using sorting, depth-first search, and duplicate-skipping backtracking.
A clear explanation of the Tenth Line shell problem using awk, sed, head, and tail.
A clear explanation of the Transpose File shell problem using awk to transform rows into columns.
Support fast prefix and suffix queries by indexing every prefix-suffix combination with the largest word index.
A clear explanation of finding the longest common contiguous subarray using dynamic programming.
A clear explanation of Permutations using depth-first search and backtracking.
A clear explanation of the Strobogrammatic Number problem using digit rotation rules and two pointers.
A clear explanation of adding an integer to an array-form number using digit-by-digit simulation.
A BFS solution for finding the minimum number of buses needed to travel from a source stop to a target stop.
A clear explanation of finding the smallest subtree that contains all deepest nodes using bottom-up DFS.
A clear explanation of counting how many words are subsequences of a string using waiting queues.
A clear explanation of splitting an array into the maximum number of chunks so sorting each chunk gives the fully sorted array.
Use binary search to find the smallest character strictly greater than the target with wraparound handling.
A clear explanation of determining whether the last character must be a one-bit character using greedy parsing.
A clear explanation of the Valid Phone Numbers shell problem using grep and regular expressions.
A clear explanation of the Word Frequency shell problem using Unix text-processing tools.
A clear explanation of Jump Game II using a greedy range expansion approach to find the minimum number of jumps.
A clear explanation of Minimum Factorization using greedy digit factors from 9 down to 2.
A clear explanation of the Shortest Word Distance III problem, including the special case where both target words are the same.
A clear explanation of Wildcard Matching using dynamic programming over string and pattern prefixes.
A clear explanation of the Shortest Word Distance II problem using preprocessing and two pointers.
A clear explanation of Multiply Strings using grade-school multiplication with digit arrays.
A clear explanation of Maximum Distance in Arrays using sorted endpoints and a greedy scan.
A clear explanation of the Shortest Word Distance problem using one pass and the latest seen indices of both words.
A clear explanation of rearranging a string so that selected characters follow a custom order.
A clear explanation of rearranging characters so no two adjacent characters are equal using a greedy max heap.
Find the time needed for a signal to reach all nodes in a directed weighted graph using Dijkstra's algorithm.
A clear explanation of designing a stack that supports push, pop, top, peekMax, and popMax.
A clear explanation of the Trapping Rain Water problem using left and right boundaries, then an optimized two-pointer solution.
A clear SQL guide for solving Combine Two Tables using LEFT JOIN.
A clear explanation of Add One Row to Tree using tree traversal and careful subtree reconnection.
A clear explanation of the First Missing Positive problem using in-place index placement to achieve O(n) time and O(1) extra space.
A clear explanation of Design Circular Queue using a fixed array, a front pointer, and a size counter.