brain
tamnd's digital brain — notes, problems, research
43815 notes
A clear explanation of reducing an integer to 1 with the fewest operations using greedy bit decisions.
A clear explanation of computing large modular exponentiation using fast power, modular arithmetic, and digit decomposition.
A clear explanation of Maximum Size Subarray Sum Equals k using prefix sums and earliest-index hashing.
A clear explanation of Wiggle Sort II using sorting, median splitting, and virtual indexing.
A clear explanation of counting connected components using Union-Find and graph traversal.
A clear explanation of maximizing the rotation function using a recurrence instead of simulating every rotation.
A clear explanation of checking whether ordered points form a convex polygon using cross products.
Count ordered boomerang tuples by fixing each point as the center and grouping other points by squared distance.
A clear explanation of uniformly picking an integer point from non-overlapping rectangles using prefix sums and binary search.
A clear explanation of checking the minimum edits needed to make a password strong using greedy handling of length, missing character types, and repeated runs.
A clear explanation of adding two integers without using plus or minus by using XOR, AND, carry, and a 32-bit mask.
A clear explanation of Intersection of Two Arrays II using frequency counting.
A clear explanation of Coin Change using dynamic programming for minimum coin count.
A clear explanation of finding the next greater element using a monotonic decreasing stack and hash map.
A clear explanation of counting battleships in a board using one-pass observation without modifying the grid.
A clear explanation of Create Maximum Number using monotonic stacks for subsequences and greedy merging.
A clear explanation of calculating total poisoned duration by merging overlapping attack intervals.
A clear explanation of validating IPv4 and IPv6 addresses by checking segment count, length, characters, range, and leading-zero rules.
Count arithmetic subsequences of length at least three using dynamic programming with one hash map per ending index.
A clear explanation of fitting a sentence onto a screen using cyclic string simulation and greedy row transitions.
A clear explanation of finding the longest substring where every character appears at least k times using divide and conquer.
A clear explanation of applying many range updates efficiently using a difference array and prefix sums.
A clear explanation of Intersection of Two Arrays using hash sets for uniqueness and fast lookup.
A clear explanation of Generalized Abbreviation using backtracking to choose whether each character is kept or abbreviated.
A dynamic programming and patience sorting solution for finding the longest strictly increasing subsequence in an array.
A clear explanation of counting sign assignments that reach a target using recursion first, then subset-sum dynamic programming.
A clear explanation of finding cells that can flow to both oceans using reverse graph traversal from the borders.
A clear explanation of counting unique substrings that appear in the infinite alphabet wraparound string using dynamic programming by ending character.
A clear explanation of Bulb Switcher using divisor parity and perfect squares.
A counting solution for producing the Bulls and Cows hint while handling duplicate digits correctly.
Add two numbers stored in forward-order linked lists using stacks and carry propagation.
A clear explanation of Design Tic-Tac-Toe using row, column, and diagonal counters for constant-time winner checks.
A clear explanation of decoding nested repeat expressions using a stack.
A clear explanation of adding one to a number stored as a linked list using the rightmost non-nine digit.
A clear explanation of counting pairs where nums[i] is greater than twice nums[j] using merge sort.
A clear explanation of Maximum Product of Word Lengths using bit masks to test disjoint character sets efficiently.
A clear explanation of deciding whether an array can be split into two equal-sum subsets using 0/1 knapsack dynamic programming.
A clear explanation of validating a byte sequence as UTF-8 using bit masks and a continuation-byte counter.
Check whether nums is the unique shortest supersequence of given subsequences using topological sorting.
A clear explanation of counting how many repeated copies of one string can be obtained as a subsequence of another repeated string.
A clear explanation of finding the largest subset where every pair is divisible using sorting, dynamic programming, and parent reconstruction.
A clear explanation of finding rectangle dimensions with a fixed area and the smallest length-width difference.
A clear explanation of Top K Frequent Elements using frequency counting and bucket sort.
A DFS solution for finding the longest parent-to-child path where each node value increases by exactly one.
A preorder DFS codec for converting a binary tree to a string and reconstructing the same tree from that string.
A clear explanation of implementing a LIFO stack using only FIFO queue operations.
Compress a character array in-place using two pointers and grouped character counting.
A clear explanation of checking whether one string is a subsequence of another using two pointers.
A clear explanation of checking whether an integer is a perfect square using binary search without sqrt.
A clear explanation of adding two non-negative integer strings using manual digit-by-digit simulation.
A clear explanation of Shortest Distance from All Buildings using BFS from each building with distance and reach accumulation.
A clear explanation of generating all distinct non-decreasing subsequences using DFS, backtracking, and per-level duplicate control.
A clear explanation of Moving Average from Data Stream using a queue and rolling sum.
A clear explanation of minimizing debt-settlement transactions using net balances, backtracking, and memoization-style pruning.
A clear explanation of evaluating an expression with plus, minus, spaces, and parentheses using a stack.
A median-based solution for minimizing total Manhattan distance in a grid.
A clear explanation of computing the total covered area of two axis-aligned rectangles by subtracting their overlap.
Find all duplicated numbers in an array in O(n) time and O(1) extra space using index marking.
Find the maximum number of complete staircase rows that can be formed using binary search and triangular numbers.
A clear explanation of finding the third distinct maximum number using one pass and constant space.
A clear explanation of Reverse Vowels of a String using two pointers and selective swaps.
A clear explanation of grouping binary tree nodes by the round in which they become leaves using postorder DFS.
A clear explanation of Remove Duplicate Letters using a greedy monotonic stack.
A clear explanation of checking whether many small axis-aligned rectangles form one exact rectangular cover using area and corner parity.
A clear explanation of the H-Index II problem using binary search on a sorted citations array.
A two-heap data structure for adding numbers from a stream and returning the current median in constant time.
A clear explanation of counting nodes in a complete binary tree faster than visiting every node.
A clear explanation of deciding whether a rolling ball can stop at the destination using BFS or DFS over stopping cells.
A clear explanation of Reverse String using two pointers and in-place swaps.
A clear explanation of counting arithmetic subarrays using dynamic programming and consecutive differences.
A clear explanation of solving the Can I Win game using minimax recursion, bitmask state compression, and memoization.
A clear explanation of Count of Smaller Numbers After Self using coordinate compression and a Fenwick Tree.
Find the k-th integer in lexicographical order without generating all numbers, using prefix counting over a conceptual trie.
A clear explanation of solving the Water and Jug Problem using Bézout's identity and greatest common divisor.
A clear explanation of finding the last remaining number after alternating left-to-right and right-to-left eliminations.
A clear explanation of the H-Index problem using sorting, then an optimized counting approach.
A recursive game theory solution with memoization for deciding whether the starting player can force a win.
A clear explanation of finding the largest square of 1s in a binary matrix using dynamic programming.
A simple string scanning solution for generating every possible next state after flipping one consecutive ++ pair into --.
A clear explanation of the Integer to English Words problem using three-digit chunks and scale words.
A game theory solution for deciding whether the first player can win by using the losing-position pattern of multiples of four.
A clear explanation of checking nearby indices with nearby values using a sliding window and bucket hashing.
A clear explanation of the Closest Binary Search Tree Value II problem using inorder traversal and a fixed-size sliding window.
A backtracking solution for matching a pattern string to a target string using a bijective character-to-substring mapping.
A clear explanation of detecting whether equal values appear within distance k using a hash map or sliding window set.
A hash map solution for checking whether a pattern string and a space-separated word string form a bijection.
A clear explanation of the Encode and Decode Strings problem using length-prefix encoding.
An in-place matrix simulation for computing the next state of Conway's Game of Life using temporary encoded states.
A clear explanation of checking whether two strings are anagrams using character frequency counting.
A clear explanation of the Closest Binary Search Tree Value problem using the BST property to walk toward the target.
A clear explanation of computing the skyline formed by buildings using sweep line and a max-heap.
A clear explanation of the Alien Dictionary problem using graph construction and topological sorting.
A clear explanation of detecting duplicates in an array using a hash set and sorting.
A clear explanation of generating all possible results from different parenthesizations using divide and conquer recursion.
A clear explanation of the Missing Number problem using sum formula and XOR.
A clear explanation of finding k distinct numbers from 1 to 9 that sum to n using backtracking.
A hash map design for checking whether a word's abbreviation is unique in a dictionary.
A clear explanation of searching a row-sorted and column-sorted matrix using the top-right corner elimination method.
A clear explanation of finding the kth largest element using sorting, a min-heap, and Quickselect.
A clear explanation of the Palindrome Permutation II problem using character counts and backtracking over half of the palindrome.