brain
tamnd's digital brain — notes, problems, research
42766 notes
A clear explanation of comparing rational numbers written as decimal strings with optional repeating parts.
A clear explanation of the Shortest Path Visiting All Nodes problem using multi-source BFS and bitmask state compression.
A clear explanation of minimizing malware spread by analyzing connected components with Union Find.
A clear explanation of matching a binary tree preorder traversal by greedily flipping nodes.
A clear explanation of the Hand of Straights problem using sorting, frequency counting, and greedy grouping.
A clear explanation of counting index triplets with duplicate values using frequency counts and combinatorics.
A clear explanation of designing an iterator over a run-length encoded sequence without expanding it.
A clear explanation of generating all powerful integers using bounded powers and a set.
A clear explanation of placing even numbers at even indices and odd numbers at odd indices using two pointers.
A clear explanation of the Longest Mountain in Array problem using peak detection and two-pointer expansion.
A clear explanation of finding the lexicographically smallest string after queue operations using rotation and sorting.
A clear explanation of sorting an array using prefix reversals by repeatedly placing the largest remaining value.
A clear explanation of merging consecutive stone piles with minimum cost using interval dynamic programming.
A clear explanation of finding the minimum banana-eating speed using binary search on the answer.
A clear explanation of making a parentheses string valid using greedy counting.
A clear explanation of the Backspace String Compare problem using stack simulation and an O(1) space two-pointer scan.
A clear explanation of solving Reveal Cards In Increasing Order using sorting and queue simulation over indices.
A counting solution for computing how many directed friend requests are allowed by age rules.
A clear explanation of counting distinct bitwise OR results from all non-empty subarrays using rolling sets.
A clear explanation of counting how many pawns a rook can capture by scanning four directions on a chessboard.
A clear explanation of placing the minimum number of cameras in a binary tree using postorder DFS.
A clear explanation of simulating robot movement on an infinite grid using direction vectors and obstacle lookup.
A clear explanation of solving Largest Time for Given Digits by checking all permutations of four digits.
A clear explanation of the Guess the Word interactive problem using candidate filtering and minimax-style guessing.
A clear explanation of counting valid music playlists using dynamic programming over playlist length and unique songs used.
A string simulation solution for converting each word in a sentence into Goat Latin.
A clear explanation of generating all n-digit numbers whose adjacent digits differ by k.
A clear explanation of inserting a value into a maximum binary tree by following the right spine.
A clear explanation of finding the longest Fibonacci-like subsequence using dynamic programming and value-to-index lookup.
A clear explanation of the Split Array into Fibonacci Sequence problem using backtracking, leading-zero checks, and 32-bit integer limits.
A clear explanation of maintaining a complete binary tree inserter using level-order indexing.
A dynamic programming solution for counting binary trees where every non-leaf node is the product of its children.
A clear explanation of solving Bag of Tokens using sorting, greedy choices, and two pointers.
A clear explanation of rearranging a binary search tree into an increasing right-only tree using inorder traversal.
A clear explanation of implementing a spellchecker with exact, case-insensitive, and vowel-error matching.
A clear explanation of identifying the town judge using trust indegree and outdegree counts.
A clear explanation of finding the maximum circular subarray sum using Kadane's algorithm.
A clear explanation of the Keys and Rooms problem using graph traversal from room 0.
A clear explanation of comparing two binary trees by collecting their leaf value sequences with DFS.
A hash set solution for finding the smallest number that can be hidden from all front-facing cards.
A clear explanation of solving Most Stones Removed with Same Row or Column using connected components and union-find.
A clear explanation of checking whether an array is monotonic using one pass and direction flags.
A clear explanation of checking whether every node in a binary tree has the same value.
A clear explanation of reversing only English letters while keeping all non-letter characters fixed.
A clear explanation of counting unique permutations where every adjacent pair sums to a perfect square using backtracking.
A clear explanation of the Magic Squares In Grid problem using fixed-size subgrid validation.
A two-pass solution for computing the shortest distance from each index to the nearest occurrence of a target character.
A clear explanation of minimizing refueling stops using a greedy max heap over reachable stations.
A clear explanation of expressing a target using the fewest operators with repeated uses of x.
A clear explanation of solving Validate Stack Sequences by simulating stack push and pop operations.
A clear explanation of designing a stack that pops the most frequent value, breaking ties by most recent insertion.
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.