brain

tamnd's digital brain — notes, problems, research

43815 notes

Appendix F. Measure and Integration

Measure theory extends the ideas of length, area, volume, and integration to more general settings. In number theory, measure appears in probability, harmonic analysis,...

number-theorybook
Prime Number Theorem

The Prime Number Theorem describes the asymptotic distribution of prime numbers. It states that

number-theorybook
Euler Criterion

Euler criterion gives an efficient way to decide whether an integer is a square modulo an odd prime. Let $p$ be an odd prime and let $a$ be an integer not divisible by $p$....

number-theorybook
Arithmetic Surfaces

Arithmetic geometry often studies families of algebraic curves varying over arithmetic bases. The most important base is

number-theorybook
Cyclotomic Fields

One of the most important classes of number fields arises from the solutions of the equation

number-theorybook
Chebyshev Bounds

The prime counting function

number-theorybook
Jacobi Symbol

The Legendre symbol

number-theorybook
Legendre Symbol

Let $p$ be an odd prime and let $a\in\mathbb{Z}$. The Legendre symbol is defined by

number-theorybook
Squares Modulo $n$

A quadratic congruence is a congruence involving a square. The basic form is

number-theorybook
Appendix E. Topology Background

Topology studies continuity, convergence, connectedness, and geometric structure in an abstract setting. In number theory, topology appears naturally in real analysis, complex...

number-theorybook
Curves over Fields

An algebraic curve is a geometric object whose dimension is one. Curves are among the oldest and most important objects in number theory and algebraic geometry.

number-theorybook
Finite Fields

The familiar fields

number-theorybook
Prime Counting Function

One of the oldest questions in number theory asks how prime numbers are distributed among the positive integers. Since primes become less frequent as numbers grow larger,...

number-theorybook
Unique Prime Factorization

The fundamental theorem of arithmetic states that every integer $n>1$ can be written as a product of prime numbers, and that this product is unique up to the order of the factors.

number-theorybook
Geometry of Diophantine Problems

A Diophantine equation is first an arithmetic object. It asks for solutions in integers or rational numbers. But every polynomial equation also defines a geometric object.

number-theorybook
Coprime Integers

Two integers $a$ and $b$, not both zero, are called coprime if their greatest common divisor is $1$:

number-theorybook
Bezout Identities

Let $a$ and $b$ be integers. An integer of the form

number-theorybook
Appendix D. Real and Complex Analysis Review

The real numbers $\mathbb{R}$ extend the rational numbers $\mathbb{Q}$ by filling gaps such as

number-theorybook
Morphisms and Fibers

Geometry is not only concerned with spaces themselves, but also with maps between spaces. In algebraic geometry and arithmetic geometry, these maps are called morphisms.

number-theorybook
Galois Groups

A polynomial equation may possess several roots related by hidden algebraic symmetries. Consider

number-theorybook
Abel Summation

In analytic number theory, one often studies sums of the form

number-theorybook
Rational and Integral Points

A central problem in number theory is to study solutions of polynomial equations whose coordinates belong to a specified number system. Two important cases are:

number-theorybook
Extended Euclidean Algorithm

The Euclidean algorithm computes the greatest common divisor of two integers. The extended Euclidean algorithm does more. It also expresses the gcd as an integer linear...

number-theorybook
Euclidean Algorithm

The greatest common divisor of two integers can be found by listing divisors, but this method becomes inefficient for large numbers. For example, finding

number-theorybook
Exponential Diophantine Equations

An exponential Diophantine equation is a Diophantine equation in which one or more unknowns appear as exponents. Typical examples include

number-theorybook
Catalan-Type Equations

A Catalan-type equation is a Diophantine equation involving powers whose values differ by a small amount. The classical example is

number-theorybook
Least Common Multiples

Let $a$ and $b$ be nonzero integers. An integer $m$ is called a common multiple of $a$ and $b$ if

number-theorybook
Convergence Methods

Analytic number theory studies infinite sums, products, and integrals. Before such expressions can be manipulated safely, one must understand the meaning of convergence.

number-theorybook
Sums of Squares

One of the oldest questions in number theory asks which integers can be written as sums of squares. Typical examples are

number-theorybook
Greatest Common Divisors

Let $a$ and $b$ be integers, not both zero. An integer $d$ is called a common divisor of $a$ and $b$ if

number-theorybook
Appendix C. Abstract Algebra Review

Abstract algebra studies sets equipped with operations. In number theory, these structures organize arithmetic behavior.

number-theorybook
Euler Products

Euler products arise when an infinite series has coefficients controlled by multiplication. The simplest and most important example is the zeta series

number-theorybook
Pell Equations

A Pell equation is a Diophantine equation of the form

number-theorybook
The Division Algorithm

The division algorithm is one of the basic structural facts about the integers. It says that any integer can be divided by a positive integer with a unique quotient and remainder.

number-theorybook
Schemes

Classical algebraic geometry studies varieties defined by polynomial equations. This theory works well over algebraically closed fields, especially over $\mathbb{C}$. However,...

number-theorybook
Splitting Fields

A central problem in algebra is to determine where a polynomial factors completely into linear terms. Consider the polynomial

number-theorybook
Infinite Products

An infinite product has the form

number-theorybook
Pythagorean Triples

A Pythagorean triple is a triple of positive integers

number-theorybook
Composite Numbers

A positive integer $n>1$ is called composite if it is not prime.

number-theorybook
Appendix B. Proof Techniques

A mathematical proof is a logically complete argument establishing the truth of a statement from accepted assumptions, definitions, and previously proved results.

number-theorybook
Prime Numbers

Prime numbers are the fundamental building blocks of arithmetic.

number-theorybook
Appendix

A set is a collection of objects, called its elements. If $x$ is an element of a set $A$, we write $x \in A$. If $x$ is not an element of $A$, we write $x \notin A$.

number-theorybook
LeetCode 925: Long Pressed Name

A clear explanation of the Long Pressed Name problem using a two-pointer scan.

leetcodestringtwo-pointers
LeetCode 975: Odd Even Jump

A clear explanation of counting good starting indices using next-jump preprocessing and dynamic programming.

leetcodearraydynamic-programmingmonotonic-stacksorting
LeetCode 850: Rectangle Area II

A clear explanation of the Rectangle Area II problem using sweep line and merged active y-intervals.

leetcodearrayordered-setsegment-treesweep-line
LeetCode 974: Subarray Sums Divisible by K

A clear explanation of counting subarrays whose sum is divisible by k using prefix sums and remainder frequencies.

leetcodearrayhash-tableprefix-sum
LeetCode 973: K Closest Points to Origin

A clear explanation of returning the k closest points to the origin using squared distance and sorting.

leetcodearraymathsortingheap
LeetCode 849: Maximize Distance to Closest Person

A clear explanation of the Maximize Distance to Closest Person problem using gaps between occupied seats.

leetcodearraytwo-pointersgreedy
LeetCode 848: Shifting Letters

A clear explanation of the Shifting Letters problem using suffix sums and modulo arithmetic.

leetcodearraystringprefix-sumsuffix-sum
LeetCode 972: Equal Rational Numbers

A clear explanation of comparing rational numbers written as decimal strings with optional repeating parts.

leetcodemathstringfractions
LeetCode 847: Shortest Path Visiting All Nodes

A clear explanation of the Shortest Path Visiting All Nodes problem using multi-source BFS and bitmask state compression.

leetcodegraphbreadth-first-searchbitmaskdynamic-programming
LeetCode 924: Minimize Malware Spread

A clear explanation of minimizing malware spread by analyzing connected components with Union Find.

leetcodegraphunion-finddepth-first-searchbreadth-first-search
LeetCode 971: Flip Binary Tree To Match Preorder Traversal

A clear explanation of matching a binary tree preorder traversal by greedily flipping nodes.

leetcodetreebinary-treedepth-first-searchgreedy
LeetCode 846: Hand of Straights

A clear explanation of the Hand of Straights problem using sorting, frequency counting, and greedy grouping.

leetcodearrayhash-tablegreedysorting
LeetCode 923: 3Sum With Multiplicity

A clear explanation of counting index triplets with duplicate values using frequency counts and combinatorics.

leetcodearrayhash-tabletwo-pointerscombinatorics
LeetCode 900: RLE Iterator

A clear explanation of designing an iterator over a run-length encoded sequence without expanding it.

leetcodearraydesigniteratorsimulation
LeetCode 970: Powerful Integers

A clear explanation of generating all powerful integers using bounded powers and a set.

leetcodemathhash-tableenumeration
LeetCode 922: Sort Array By Parity II

A clear explanation of placing even numbers at even indices and odd numbers at odd indices using two pointers.

leetcodearraytwo-pointerssorting
LeetCode 845: Longest Mountain in Array

A clear explanation of the Longest Mountain in Array problem using peak detection and two-pointer expansion.

leetcodearraytwo-pointers
LeetCode 899: Orderly Queue

A clear explanation of finding the lexicographically smallest string after queue operations using rotation and sorting.

leetcodestringmathsorting
LeetCode 969: Pancake Sorting

A clear explanation of sorting an array using prefix reversals by repeatedly placing the largest remaining value.

leetcodearraysortinggreedy
LeetCode 1000: Minimum Cost to Merge Stones

A clear explanation of merging consecutive stone piles with minimum cost using interval dynamic programming.

leetcodearraydynamic-programminginterval-dpprefix-sum
LeetCode 875: Koko Eating Bananas

A clear explanation of finding the minimum banana-eating speed using binary search on the answer.

leetcodearraybinary-search
LeetCode 921: Minimum Add to Make Parentheses Valid

A clear explanation of making a parentheses string valid using greedy counting.

leetcodestringstackgreedycounting
LeetCode 844: Backspace String Compare

A clear explanation of the Backspace String Compare problem using stack simulation and an O(1) space two-pointer scan.

leetcodestringstacktwo-pointerssimulation
LeetCode 950: Reveal Cards In Increasing Order

A clear explanation of solving Reveal Cards In Increasing Order using sorting and queue simulation over indices.

leetcodearrayqueuesortingsimulation
LeetCode 825: Friends Of Appropriate Ages

A counting solution for computing how many directed friend requests are allowed by age rules.

leetcodearraycountingprefix-sum
LeetCode 898: Bitwise ORs of Subarrays

A clear explanation of counting distinct bitwise OR results from all non-empty subarrays using rolling sets.

leetcodearraydynamic-programmingbit-manipulationset
LeetCode 999: Available Captures for Rook

A clear explanation of counting how many pawns a rook can capture by scanning four directions on a chessboard.

leetcodearraymatrixsimulation
LeetCode 968: Binary Tree Cameras

A clear explanation of placing the minimum number of cameras in a binary tree using postorder DFS.

leetcodetreebinary-treedepth-first-searchgreedy
LeetCode 874: Walking Robot Simulation

A clear explanation of simulating robot movement on an infinite grid using direction vectors and obstacle lookup.

leetcodesimulationhash-setarray
LeetCode 949: Largest Time for Given Digits

A clear explanation of solving Largest Time for Given Digits by checking all permutations of four digits.

leetcodearraystringpermutationbrute-force
LeetCode 843: Guess the Word

A clear explanation of the Guess the Word interactive problem using candidate filtering and minimax-style guessing.

leetcodearraystringinteractivegame-theoryminimax
LeetCode 920: Number of Music Playlists

A clear explanation of counting valid music playlists using dynamic programming over playlist length and unique songs used.

leetcodedynamic-programmingcombinatoricsmath
LeetCode 824: Goat Latin

A string simulation solution for converting each word in a sentence into Goat Latin.

leetcodestringsimulation
LeetCode 967: Numbers With Same Consecutive Differences

A clear explanation of generating all n-digit numbers whose adjacent digits differ by k.

leetcodebacktrackingdepth-first-searchbreadth-first-search
LeetCode 998: Maximum Binary Tree II

A clear explanation of inserting a value into a maximum binary tree by following the right spine.

leetcodetreebinary-treerecursion
LeetCode 873: Length of Longest Fibonacci Subsequence

A clear explanation of finding the longest Fibonacci-like subsequence using dynamic programming and value-to-index lookup.

leetcodearraydynamic-programminghash-table
LeetCode 842: Split Array into Fibonacci Sequence

A clear explanation of the Split Array into Fibonacci Sequence problem using backtracking, leading-zero checks, and 32-bit integer limits.

leetcodestringbacktrackingdepth-first-search
LeetCode 919: Complete Binary Tree Inserter

A clear explanation of maintaining a complete binary tree inserter using level-order indexing.

leetcodetreebinary-treebreadth-first-searchdesign
LeetCode 823: Binary Trees With Factors

A dynamic programming solution for counting binary trees where every non-leaf node is the product of its children.

leetcodedynamic-programmingarrayhash-mapsorting
LeetCode 948: Bag of Tokens

A clear explanation of solving Bag of Tokens using sorting, greedy choices, and two pointers.

leetcodearraygreedysortingtwo-pointers
LeetCode 897: Increasing Order Search Tree

A clear explanation of rearranging a binary search tree into an increasing right-only tree using inorder traversal.

leetcodetreebinary-treebinary-search-treedfsinorder-traversal
LeetCode 966: Vowel Spellchecker

A clear explanation of implementing a spellchecker with exact, case-insensitive, and vowel-error matching.

leetcodearraystringhash-table
LeetCode 997: Find the Town Judge

A clear explanation of identifying the town judge using trust indegree and outdegree counts.

leetcodearraygraphcounting
LeetCode 918: Maximum Sum Circular Subarray

A clear explanation of finding the maximum circular subarray sum using Kadane's algorithm.

leetcodearraydynamic-programmingkadane-algorithm
LeetCode 841: Keys and Rooms

A clear explanation of the Keys and Rooms problem using graph traversal from room 0.

leetcodegraphdepth-first-searchbreadth-first-search
LeetCode 872: Leaf-Similar Trees

A clear explanation of comparing two binary trees by collecting their leaf value sequences with DFS.

leetcodetreebinary-treedfs
LeetCode 822: Card Flipping Game

A hash set solution for finding the smallest number that can be hidden from all front-facing cards.

leetcodearrayhash-set
LeetCode 947: Most Stones Removed with Same Row or Column

A clear explanation of solving Most Stones Removed with Same Row or Column using connected components and union-find.

leetcodegraphunion-finddepth-first-search
LeetCode 896: Monotonic Array

A clear explanation of checking whether an array is monotonic using one pass and direction flags.

leetcodearray
LeetCode 965: Univalued Binary Tree

A clear explanation of checking whether every node in a binary tree has the same value.

leetcodetreebinary-treedepth-first-searchrecursion
LeetCode 917: Reverse Only Letters

A clear explanation of reversing only English letters while keeping all non-letter characters fixed.

leetcodestringtwo-pointers
LeetCode 996: Number of Squareful Arrays

A clear explanation of counting unique permutations where every adjacent pair sums to a perfect square using backtracking.

leetcodearraybacktrackinggraphcounting
LeetCode 840: Magic Squares In Grid

A clear explanation of the Magic Squares In Grid problem using fixed-size subgrid validation.

leetcodearraymatrixsimulation
LeetCode 821: Shortest Distance to a Character

A two-pass solution for computing the shortest distance from each index to the nearest occurrence of a target character.

leetcodearraystringtwo-pointers
LeetCode 871: Minimum Number of Refueling Stops

A clear explanation of minimizing refueling stops using a greedy max heap over reachable stations.

leetcodegreedyheappriority-queuearray
LeetCode 964: Least Operators to Express Number

A clear explanation of expressing a target using the fewest operators with repeated uses of x.

leetcodemathdynamic-programmingdfsmemoization
LeetCode 946: Validate Stack Sequences

A clear explanation of solving Validate Stack Sequences by simulating stack push and pop operations.

leetcodearraystacksimulation
LeetCode 895: Maximum Frequency Stack

A clear explanation of designing a stack that pops the most frequent value, breaking ties by most recent insertion.

leetcodehash-tablestackdesign