RunTimeFix
fn solve(n: i32) -> i32 {
if n < 2 { return n; }
let (a, b) = (0, 1);
for _ in 0..n {
(a, b) = (b, a + b);
}
b
}RunTimeFix
175 downloads
by RunTimeFix
From LeetCode to Codeforces — build the algorithmic intuition that separates elite competitors from everyone else.
A practical, no-fluff guide to competitive programming. Instead of reciting definitions, this book teaches you how to think about problems: recognizing patterns, proving complexity, and translating insight into clean, fast C++ code.
Free account required. PDF, 272 pages · ~4 MB.
Book series
Start with Part 1 for free. Later parts go deeper into the algorithms and strategy that win rated contests.
From LeetCode to Codeforces — build the algorithmic intuition that separates elite competitors from everyone else.
272 pages
Sign UpSegment trees, Fenwick trees, advanced DP, and the algorithms that decide rated contests.
Pages TBD
Coming soon30 chapters, taken straight from the book's index — written to be read front to back, each one builds on the last.
Program Structure & Compilation · Variables & Data Types · Arithmetic Operations & Modulo · Integer Overflow & The 1LL Trick · Input/Output Streams & Fast I/O · Conditionals & Logical Operators
The Three Loop Structures · Loop Controls: break & continue · Nested Loops · Core Loop Patterns
1D Arrays (C-Style) · 2D Arrays & Row-Major Layout · std::string & Character Operations
Function Mechanics & Variable Scope · Parameter Passing: Value vs. Reference · Recursion & the Call Stack
std::string in C++ · Character Operations & ASCII Mathematics
Structures (Structs) in C++ · Lambdas & Inline Comparators · auto & Structured Bindings (C++17)
Graph theory mastery, flows, and the contest-strategy playbook for climbing ratings.
Pages TBD
Coming soonThe C++ Preprocessor & Macros · Compilation Pipeline & G++ Compiler Flags
std::vector — The Dynamic Array · std::pair — Grouping Two Values · std::tuple — Grouping Three or More Values (D1) · String STL Methods (Advanced) · Iterators — The Bridge Between Containers and Algorithms · Utility Algorithms
std::set — Ordered Unique Elements · std::multiset — Ordered Elements with Duplicates · std::map — Key-Value Associations · std::unordered_map & std::unordered_set — Hash-Based Containers · std::stack — LIFO Container Adapter · std::queue — FIFO Container Adapter · std::deque — Double-Ended Queue · std::priority_queue — Heap-Based Container
std::sort — The Workhorse · lower_bound & upper_bound — Binary Search in STL · binary_search — Boolean Existence Check · unique — Removing Consecutive Duplicates · next_permutation — Generating Permutations · Sorting Applications · Frequency Counting
Reading Problem Statements · Complexity Analysis · Brute Force · Observation Finding · Edge-Case Handling · Debugging Techniques · Stress Testing
Divisibility · GCD & LCM · Primes & Primality Testing · Sieve of Eratosthenes · Prime Factorization · Divisor Enumeration · Modular Arithmetic · Binary Exponentiation · Parity Arguments · Sum Formulas
1D Prefix Sums · 2D Prefix Sums · Suffix Sums & Suffix Aggregates · Difference Arrays
Two Pointers (Opposite Direction) · Two Pointers (Same Direction) · Sliding Window (Fixed Size) · Sliding Window (Variable Size)
Binary Search on a Sorted Array · STL Binary Search Functions · Binary Search on the Answer · Boundary Handling
The Greedy Paradigm · Sorting-Based Greedy · Interval Scheduling (Activity Selection) · The Exchange Argument · Constructive Algorithms
Bitwise Operators · Bit Tricks · XOR Properties · Bitmask Enumeration · __builtin Functions
Stack Applications · Queue Applications · Monotonic Stack · Monotonic Deque (Sliding Window Min/Max)
The Problem DSU Solves · Naive Implementation · Optimization 1: Path Compression · Optimization 2: Union by Rank/Size · Component Queries
Coordinate Compression · Fenwick Tree (Binary Indexed Tree) · Segment Tree · Sparse Table (D1 — Recognition)
Graph Terminology · Graph Representation · DFS on Graphs · BFS on Graphs · Connected Components · Grid Traversal
Cycle Detection in Undirected Graphs · Cycle Detection in Directed Graphs · Bipartite Checking · Topological Sort · DAG Reasoning · Functional Graphs
Dijkstra's Algorithm · 0-1 BFS · Minimum Spanning Tree — Kruskal's Algorithm
Tree Terminology · Rooting a Tree · Tree Diameter · Distance Between Two Vertices · Tree Algorithms: Summary of Techniques
Binary Lifting · Lowest Common Ancestor (LCA) · Euler Tour
The DP Paradigm · The DP Recipe · Classic DP Problems · Longest Increasing Subsequence (LIS) · Maximum Subarray Sum (Kadane's Algorithm)
The 0-1 Knapsack Problem · Unbounded Knapsack · Subset Sum & Knapsack Variants · Bitmask DP
The Backtracking Template · Generating Combinatorial Objects · Pruning · Meet-in-the-Middle
Modular Multiplicative Inverse · Combinatorics: C(N, K) mod M · Common Combinatorial Problems · Matrix Exponentiation (Fast Math)
Polynomial Rolling Hashing · The Trie (Prefix Tree) · Geometry: The Cross Product · Book 1 Conclusion