Part 11•Chapter 7 of 9•Advanced
Greedy, Backtracking, Bit Hacks, Math & Advanced (55 Problems)
55 problems covering interval scheduling, N-Queens, bitmask combinatorics, prime factorizations, and Segment Trees.
~22 min read
4,296 words
7 Sections
Reviewed & Verified (2024 Syllabus)
55 Solved ProblemsInterval SchedulingBitwise Subset Combinations
Heuristic choices, exhaustive tree searches, low-level bitwise operations, and discrete number theory resolve problems where standard polynomial dynamic programming is unavailable. This volume compiles 55 signature problems spanning greedy interval scheduling, backtracking pruning constraints, bitwise bitmask manipulations, modular arithmetic, and geometric algorithms.
1. Executive Summary & Learning Objectives
#This problem bank codifies 55 essential challenges spanning greedy interval optimization, combinatorial backtracking, bit hacks, number theory, and computational geometry.
By completing this problem set, you will be able to:
- Apply Greedy Choice Principles: Prove matroid exchange properties for earliest-deadline-first interval scheduling and gas station tour invariants in time.
- Prune Backtracking Search Spaces: Formulate state-space trees with bitmask constraint propagation to solve N-Queens, Sudoku, and Word Search in optimal time.
- Execute Single-Cycle Bit Manipulation: Use bitwise primitives (
n & (n - 1), single-number XOR, submask enumeration) for high-performance set algebra. - Implement Foundational Number Theory: Construct Sieve of Eratosthenes primes, Extended Euclidean GCD, and binary exponentiation in time.
- Formulate Geometric & Transform Algorithms: Implement Graham Scan convex hulls, orientation cross-products, and Fast Fourier Transform (FFT) polynomial convolutions in time.
2. Problem Taxonomy & Architecture Guide
#| Section | Problem Range | Primary Patterns Covered | Target Complexity Range |
|---|---|---|---|
| Section 1 | Q471 – Q482 | Greedy Intervals, Sweepline & Task Scheduling | to Time, to Space |
| Section 2 | Q483 – Q495 | Backtracking, Permutations, Subsets & Constraint Satisfaction | Exponential Time with Strict Pruning, Stack Space |
| Section 3 | Q496 – Q505 | Bit Manipulation Hacks, Masking & ALU Tricks | to Time, Space |
| Section 4 | Q506 – Q515 | Number Theory, Modular Arithmetic & Primality | to Time, Space |
| Section 5 | Q516 – Q525 | Computational Geometry, Game Theory & FFT Convolutions | to Time, Space |
Section 1: Greedy Intervals & Scheduling (Q471 – Q482)
#Q471: Merge Intervals
- Difficulty:
[Medium]| Pattern:[Interval Sort & Merge] - Statement: Merge overlapping intervals.
- Optimal Approach: Sort intervals by start time. Iterate: if
curr.start <= prev.end, merge by updatingprev.end = max(prev.end, curr.end); else append new interval. - Complexity: Time: | Space:
- Edge Cases: Single interval, adjacent non-overlapping intervals (
[1, 4]and[5, 6]).
Q472: Insert Interval
- Difficulty:
[Medium]| Pattern:[Three-Stage Interval Walk] - Statement: Insert new interval into sorted non-overlapping interval list and merge if necessary.
- Optimal Approach: 1. Add all intervals ending before
newInterval.start. 2. Merge all overlapping intervals intonewInterval. 3. Add all intervals starting afternewInterval.end. - Complexity: Time: strictly linear | Space:
- Edge Cases: New interval inserted at very beginning or very end.
Q473: Non-Overlapping Intervals
- Difficulty:
[Medium]| Pattern:[Greedy Earliest Deadline First] - Statement: Find minimum number of intervals to remove to make remainder non-overlapping.
- Optimal Approach: Sort intervals by end time ascending. Greedily keep interval that finishes earliest; if next interval starts before current finish, increment removal count.
- Complexity: Time: | Space: auxiliary
- Edge Cases: Intervals sharing endpoints (
[1, 2]and[2, 3]do NOT overlap).
Q474: Minimum Number of Arrows to Burst Balloons
- Difficulty:
[Medium]| Pattern:[Interval Endpoint Greedy] - Statement: Balloons represented as intervals . Find min arrows shot vertically to burst all.
- Optimal Approach: Sort by end coordinate. Shoot arrow at
balloon[0].end. Skip all balloons overlapping with this arrow position; shoot new arrow when non-overlapping balloon seen. - Complexity: Time: | Space:
- Edge Cases: Coordinate values at
INT_MAX(use comparison function, avoida - bsubtraction overflow).
Q475: Meeting Rooms
- Difficulty:
[Easy]| Pattern:[Sort Adjacent Overlap Check] - Statement: Determine if a person could attend all meetings.
- Optimal Approach: Sort intervals by start time. Check if any adjacent pair has
intervals[i].start < intervals[i-1].end. - Complexity: Time: | Space:
- Edge Cases: 0 or 1 meeting (always true).
Q476: Meeting Rooms II
- Difficulty:
[Medium]| Pattern:[Chronological Event Sweepline / Min-Heap] - Statement: Find minimum conference rooms required to host all meetings.
- Optimal Approach: Sort start times and end times separately. Pointers
sande. Ifstart[s] < end[e], need new room (rooms++,s++); else room freed (e++,s++). - Complexity: Time: | Space:
- Edge Cases: Meetings ending and starting at exact same time (room can be reused immediately).
Q477: Jump Game
- Difficulty:
[Medium]| Pattern:[Greedy Furthest Reach] - Statement: Can you reach last index starting from index 0 jumping at most
nums[i]steps? - Optimal Approach: Track
maxReach. At index : if , returnfalse. UpdatemaxReach = max(maxReach, i + nums[i]). ReturnmaxReach >= n - 1. - Complexity: Time: | Space:
- Edge Cases: Array with zeroes trapping traversal, length 1.
Q478: Jump Game II
- Difficulty:
[Medium]| Pattern:[BFS Window / Greedy Jumps] - Statement: Minimum jumps to reach last index.
- Optimal Approach: Track
currentJumpEndandfurthestReach. Iterate . UpdatefurthestReach = max(furthestReach, i + nums[i]). When , jump (jumps++,currentJumpEnd = furthestReach). - Complexity: Time: | Space:
- Edge Cases: Length 1 (0 jumps).
Q479: Gas Station
- Difficulty:
[Medium]| Pattern:[Greedy Deficit Reset] - Statement: Complete circular tour of gas stations. Find starting station index.
- Optimal Approach: Total gas must be total cost. Maintain
tank. Iftank < 0, resetstart = i + 1andtank = 0. - Complexity: Time: | Space:
- Edge Cases: Sum of gas strictly less than sum of cost (impossible, returns ).
Q480: Candy
- Difficulty:
[Hard]| Pattern:[Two-Pass Left & Right Greedy] - Statement: Children with higher rating than neighbor must get more candies. Minimize candies.
- Optimal Approach: Initialize all with 1 candy. Left-to-right pass: if , set . Right-to-left pass: if , set .
- Complexity: Time: | Space:
- Edge Cases: Strictly decreasing ratings, all ratings identical.
Q481: Lemonade Change
- Difficulty:
[Easy]| Pattern:[Greedy Bill Prioritization] - Statement: Customers pay with <span class="katex-error" title="ParseError: KaTeX parse error: Unexpected character: '' at position 4: 5, \̲" style="color:#cc0000">5, </span>10, $20. Can you provide correct change to everyone?
- Optimal Approach: Track count of <span class="katex-error" title="ParseError: KaTeX parse error: Unexpected character: '' at position 7: 5 and \̲" style="color:#cc0000">5 and </span>10 bills. For <span class="katex-error" title="ParseError: KaTeX parse error: Unexpected character: '' at position 10: 10, give \̲" style="color:#cc0000">10, give </span>5. For <span class="katex-error" title="ParseError: KaTeX parse error: Unexpected character: '' at position 23: …edily give one \̲" style="color:#cc0000">20, greedily give one </span>10 and one <span class="katex-error" title="ParseError: KaTeX parse error: Unexpected character: '' at position 10: 5 (saves \̲" style="color:#cc0000">5 (saves </span>5 bills for future change!).
- Complexity: Time: | Space:
- Edge Cases: First customer pays with <span class="katex-error" title="ParseError: KaTeX parse error: Unexpected character: '' at position 7: 10 or \̲" style="color:#cc0000">10 or </span>20 (cannot give change).
Q482: Queue Reconstruction by Height
- Difficulty:
[Medium]| Pattern:[Sort Tallest First + Greedy Insert] - Statement: Reconstruct queue where person has exactly taller or equal people in front.
- Optimal Approach: Sort people by height descending; on height ties, sort by ascending. Iterate and insert each person into output list at index !
- Complexity: Time: | Space:
- Edge Cases: All people have identical height.
Section 2: Backtracking & Combinatorial Search (Q483 – Q497)
#Q483: Subsets
- Difficulty:
[Medium]| Pattern:[Cascading / Backtracking Power Set] - Statement: Return all possible subsets (power set) of distinct integers.
- Optimal Approach: Backtracking
dfs(start, path). At each call, add copy ofpathto results. Loop from to , push , recurse , pop. - Complexity: Time: | Space: recursion
- Edge Cases: Empty array (returns
[[]]).
Q484: Subsets II
- Difficulty:
[Medium]| Pattern:[Sort + Duplicate Skip Backtracking] - Statement: Return all unique subsets from array that may contain duplicates.
- Optimal Approach: Sort array. In loop from to , skip duplicates:
if (i > start && nums[i] == nums[i-1]) continue. - Complexity: Time: | Space:
- Edge Cases: All elements identical.
Q485: Permutations
- Difficulty:
[Medium]| Pattern:[In-Place Element Swapping / Visited Set] - Statement: Return all permutations of distinct integers.
- Optimal Approach:
backtrack(first): loop from to , swap with , recurse on , swap back. - Complexity: Time: | Space:
- Edge Cases: Array with 1 element.
Q486: Permutations II
- Difficulty:
[Medium]| Pattern:[Sort + Visited Duplicate Pruning] - Statement: Return unique permutations of array containing duplicates.
- Optimal Approach: Sort array. Boolean
usedarray. Skip ifused[i]ori > 0 && nums[i] == nums[i-1] && !used[i-1]. - Complexity: Time: | Space:
- Edge Cases: Array with all duplicate elements.
Q487: Combinations
- Difficulty:
[Medium]| Pattern:[Size K Backtracking] - Statement: Return all combinations of numbers chosen from .
- Optimal Approach: Backtrack tracking current number and path. Prune search if remaining numbers cannot fill path:
if (path.size() + (n - start + 1) < k) return. - Complexity: Time: | Space:
- Edge Cases: .
Q488: Combination Sum
- Difficulty:
[Medium]| Pattern:[Unlimited Reuse Backtracking] - Statement: Return unique combinations summing to target; same number may be used unlimited times.
- Optimal Approach: Recurse
backtrack(start, remaining): loop from , subtract , recurse on same index (backtrack(i, remaining - nums[i])). - Complexity: Time: | Space:
- Edge Cases: Target smaller than all numbers.
Q489: Combination Sum II
- Difficulty:
[Medium]| Pattern:[No Reuse Duplicate Skip Backtracking] - Statement: Each number used at most once; input has duplicates. Sum to target.
- Optimal Approach: Sort array. Loop from : skip
if (i > start && nums[i] == nums[i-1]). Recurse oni + 1. - Complexity: Time: | Space:
- Edge Cases: Multiple identical numbers needed to reach target.
Q490: Combination Sum III
- Difficulty:
[Medium]| Pattern:[Bounded Digits 1-9 Backtracking] - Statement: Find all combinations of numbers from that sum to .
- Optimal Approach: Backtrack choosing digits . Stop when
path.size() == kandtarget == 0. - Complexity: Time: | Space:
- Edge Cases: too large to form with digits.
Q491: Letter Combinations of a Phone Number
- Difficulty:
[Medium]| Pattern:[Branching Digits Backtracking] - Statement: Return all letter combinations for phone digits mapping
2-9. - Optimal Approach: Array mapping digit to letters. Backtrack index by index in digit string, looping over mapped letters.
- Complexity: Time: | Space:
- Edge Cases: Empty digit string (returns
[]).
Q492: Generate Parentheses
- Difficulty:
[Medium]| Pattern:[Count-Constrained Backtracking] - Statement: Generate all well-formed parentheses strings of pairs.
- Optimal Approach: Maintain
openandclosecounts. Ifopen < n, add(and recurse. Ifclose < open, add)and recurse. - Complexity: Time: (Catalan number ) | Space:
- Edge Cases: (
"()").
Q493: N-Queens
- Difficulty:
[Hard]| Pattern:[Bitmask / Set Diagonal Constraint Backtracking] - Statement: Place queens on chessboard so no two queens attack each other.
- Optimal Approach: Row-by-row recursion. Maintain sets/bitmasks for occupied
cols, major diagonalsr - c, and minor diagonalsr + c. - Complexity: Time: | Space:
- Edge Cases: (1 solution), (0 solutions).
Q494: N-Queens II
- Difficulty:
[Hard]| Pattern:[Bitmask Solution Counter] - Statement: Return total number of distinct solutions to the -queens puzzle.
- Optimal Approach: Bitmask state
solve(row, cols, diag1, diag2). Available positions calculated in via bitwise~ (cols | diag1 | diag2). - Complexity: Time: | Space:
- Edge Cases: (2 solutions).
Q495: Sudoku Solver
- Difficulty:
[Hard]| Pattern:[Exact Cover / Constraint Propagation Backtracking] - Statement: Solve Sudoku puzzle modifying board in-place.
- Optimal Approach: Find next empty cell. Try digits ; verify validity across row, column, and box. If valid, recurse; if recursion fails, reset to .
- Complexity: Time: worst case, heavily pruned in practice | Space:
- Edge Cases: Unique solution guaranteed per problem description.
Q496: Word Search
- Difficulty:
[Medium]| Pattern:[2D Grid DFS Backtracking with In-Place Visited] - Statement: Check if word exists in grid moving horizontally/vertically without reusing cell.
- Optimal Approach: At cell , match . Temporarily set to mark visited. Explore 4 neighbors, restore character on return.
- Complexity: Time: | Space:
- Edge Cases: Word longer than total cells in board.
Q497: Palindrome Partitioning
- Difficulty:
[Medium]| Pattern:[Backtracking with Palindrome Substring Check] - Statement: Partition string such that every substring is a palindrome.
- Optimal Approach: For start index, try all end indices. If substring is a palindrome, append to current path and recurse on .
- Complexity: Time: | Space:
- Edge Cases: String of all identical characters.
Section 3: Bit Manipulation & Hacks (Q498 – Q507)
#Q498: Single Number
- Difficulty:
[Easy]| Pattern:[XOR Self-Cancellation] - Statement: Every element appears twice except for one. Find it in space.
- Optimal Approach: XOR all elements together: and . All pairs cancel out, leaving single number.
- Complexity: Time: | Space:
- Edge Cases: Single element array.
Q499: Single Number II
- Difficulty:
[Medium]| Pattern:[Bit Count Modulo 3 / Digital State Logic] - Statement: Every element appears 3 times except one. Find it.
- Optimal Approach: Count number of 1s at each bit position . Take sum modulo 3. Resulting bits form the single number. Or two variables
onesandtwos. - Complexity: Time: | Space:
- Edge Cases: Negative single number.
Q500: Single Number III
- Difficulty:
[Medium]| Pattern:[XOR Partitioning by Lowest Set Bit] - Statement: Exactly two numbers appear once; all others appear twice. Find the two numbers.
- Optimal Approach: XOR all elements to get . Find lowest set bit in :
diff = X & (-X). Partition array into two groups based on this bit and XOR each group separately! - Complexity: Time: | Space:
- Edge Cases: Overflow on
INT_MIN & (-INT_MIN)(cast to 64-bit int).
Q501: Number of 1 Bits (Hamming Weight)
- Difficulty:
[Easy]| Pattern:[Brian Kernighan's Algorithm] - Statement: Return number of set bits in unsigned integer.
- Optimal Approach: While , set and increment count. (Clears the lowest set bit in exactly steps!).
- Complexity: Time: | Space:
- Edge Cases: .
Q502: Counting Bits
- Difficulty:
[Easy]| Pattern:[Bit DP Relation] - Statement: For all , count set bits in time.
- Optimal Approach: . Or .
- Complexity: Time: strictly linear | Space:
- Edge Cases: .
Q503: Reverse Bits
- Difficulty:
[Easy]| Pattern:[32-Bit Shift Assembly] - Statement: Reverse bits of a 32-bit unsigned integer.
- Optimal Approach: Loop 32 times:
ans = (ans << 1) | (n & 1), thenn = n >> 1. - Complexity: Time: | Space:
- Edge Cases: All bits 1, all bits 0.
Q504: Bitwise AND of Numbers Range
- Difficulty:
[Medium]| Pattern:[Common Binary Prefix] - Statement: Return bitwise AND of all numbers in .
- Optimal Approach: Find common binary prefix of and ! Shift both right until , then shift back.
- Complexity: Time: | Space:
- Edge Cases: (result 0).
Q505: Power of Two
- Difficulty:
[Easy]| Pattern:[Single Set Bit Test] - Statement: Check if is a power of 2.
- Optimal Approach: Return
n > 0 && (n & (n - 1)) == 0. - Complexity: Time: | Space:
- Edge Cases: (must return false).
Q506: Subsets Using Bit Manipulation
- Difficulty:
[Medium]| Pattern:[Binary Mask Generation] - Statement: Generate all subsets using binary numbers .
- Optimal Approach: Loop . If -th bit of is 1, include in subset.
- Complexity: Time: | Space: auxiliary
- Edge Cases: .
Q507: Maximum Product of Word Lengths
- Difficulty:
[Medium]| Pattern:[26-Bit Character Bitmask] - Statement: Find max where words share no common letters.
- Optimal Approach: Encode each word as 26-bit bitmask where bit if character is present. Two words share no letters iff
mask1 & mask2 == 0. - Complexity: Time: | Space:
- Edge Cases: All pairs share characters (returns 0).
Section 4: Math, Number Theory & Geometry (Q508 – Q525)
#Q508: Count Primes (Sieve of Eratosthenes)
- Difficulty:
[Medium]| Pattern:[Sieve Prime Sieving] - Statement: Count primes strictly less than .
- Optimal Approach: Boolean array of size initialized to true. For , if , cross off all multiples from step .
- Complexity: Time: | Space:
- Edge Cases: (0 primes).
Q509: Greatest Common Divisor (Euclidean Algorithm)
- Difficulty:
[Easy]| Pattern:[Euclidean Modulo Recursion] - Statement: Compute in time.
- Optimal Approach: While , . Return .
- Complexity: Time: | Space:
- Edge Cases: .
Q510: Pow(x, n) (Binary Exponentiation)
- Difficulty:
[Medium]| Pattern:[Exponent Halving Multiplication] - Statement: Calculate in time.
- Optimal Approach: If , invert . While : if is odd, multiply result by ; square ; divide .
- Complexity: Time: | Space:
- Edge Cases: (negation overflows 32-bit int; cast to 64-bit int), .
Q511: Factorial Trailing Zeroes
- Difficulty:
[Medium]| Pattern:[Legendre's Formula (Factors of 5)] - Statement: Count trailing zeroes in .
- Optimal Approach: Count factors of 5: . In loop: .
- Complexity: Time: | Space:
- Edge Cases: .
Q512: Happy Number
- Difficulty:
[Easy]| Pattern:[Sum of Squares Digits Cycle Detection] - Statement: Replace number by sum of squares of digits; reaches 1 or loops in cycle.
- Optimal Approach: Fast and slow pointers on transformation function. If fast meets 1, happy; if fast meets slow, cycle detected!
- Complexity: Time: | Space:
- Edge Cases: .
Q513: Roman to Integer & Integer to Roman
- Difficulty:
[Medium]| Pattern:[Greedy Decreasing Subtraction] - Statement: Convert Roman numeral to integer and integer to Roman.
- Optimal Approach: For Roman to Int: if current symbol next symbol, subtract; else add. For Int to Roman: greedy array of 13 value-symbol pairs descending.
- Complexity: Time: | Space:
- Edge Cases: Subtractive notation (
IV,IX,CD).
Q514: Excel Sheet Column Title & Number
- Difficulty:
[Easy]| Pattern:[Base-26 with 1-Based Offset] - Statement: Convert column number to title (
1 -> "A",28 -> "AB") and vice versa. - Optimal Approach: Number to Title: while , decrement , extract char , divide . Title to Number: multiply by 26 and add digit.
- Complexity: Time: | Space:
- Edge Cases: Multiples of 26 (
"Z","AZ").
Q515: Angle Between Hands of a Clock
- Difficulty:
[Medium]| Pattern:[Hour & Minute Angles Difference] - Statement: Calculate smaller angle between hour and minute hands.
- Optimal Approach: Minute angle . Hour angle . Difference ; return .
- Complexity: Time: | Space:
- Edge Cases: 12 o'clock, 6 o'clock ().
Q516: Convex Hull (Monotone Chain Algorithm)
- Difficulty:
[Hard]| Pattern:[Cross Product Orientation] - Statement: Find smallest convex polygon that encloses all given points.
- Optimal Approach: Andrew's Monotone Chain: sort points. Build lower hull using 2D cross product: (turn left). Repeat for upper hull.
- Complexity: Time: | Space:
- Edge Cases: Collinear points, all points identical.
Q517: Point Inside Polygon (Ray Casting)
- Difficulty:
[Medium]| Pattern:[Jordan Curve Theorem Ray Casting] - Statement: Determine if point lies inside arbitrary polygon.
- Optimal Approach: Cast horizontal ray from to infinity. Count intersections with polygon edges. If intersection count is odd, inside; if even, outside.
- Complexity: Time: | Space:
- Edge Cases: Point on edge or vertex.
Q518: Line Segment Intersection
- Difficulty:
[Hard]| Pattern:[Orientation CCW Checks] - Statement: Check if segment intersects segment .
- Optimal Approach: Check orientations of triplets and . Intersects if orientations alternate, or if collinear and project overlaps.
- Complexity: Time: | Space:
- Edge Cases: Collinear segments overlapping.
Q519: Max Points on a Line (GCD Slopes)
- Difficulty:
[Hard]| Pattern:[Coprime Slope Fractions] - Statement: Find maximum points on any single line.
- Optimal Approach: For each point , hash map stores slopes to point as preserving exact rational value.
- Complexity: Time: | Space:
- Edge Cases: Duplicate points, vertical lines.
Q520: Rectangle Area
- Difficulty:
[Medium]| Pattern:[Inclusion-Exclusion 2D] - Statement: Total area covered by two rectilinear rectangles.
- Optimal Approach: . Overlap width is . Overlap height is .
- Complexity: Time: | Space:
- Edge Cases: Rectangles do not overlap (overlap area 0).
Q521: Perfect Number
- Difficulty:
[Easy]| Pattern:[Divisor Enumeration up to Sqrt] - Statement: Check if positive integer equals sum of all its proper divisors.
- Optimal Approach: Sum divisors up to . If divides , add and . Compare with .
- Complexity: Time: | Space:
- Edge Cases: (not perfect).
Q522: Reverse Integer
- Difficulty:
[Medium]| Pattern:[Arithmetic Digit Shift with Safe Clamping] - Statement: Reverse digits of 32-bit signed integer; return 0 if reversed overflows.
- Optimal Approach: Pop digit:
digit = x % 10, x /= 10. Checkans > INT_MAX / 10 || (ans == INT_MAX / 10 && digit > 7)before multiplying by 10. - Complexity: Time: | Space:
- Edge Cases: Negative numbers, numbers ending with zeroes.
Q523: Palindrome Number
- Difficulty:
[Easy]| Pattern:[Reverse Half the Digits] - Statement: Determine if integer is a palindrome without converting to string.
- Optimal Approach: Negative numbers never palindromes. While , pop digit and add to . Palindrome iff .
- Complexity: Time: | Space:
- Edge Cases: Numbers ending in 0 (except 0 itself) are not palindromes.
Q524: Nim Game / Stone Game
- Difficulty:
[Easy]| Pattern:[Game Theory Invariant] - Statement: Players remove 1, 2, or 3 stones. Can you win starting first with stones?
- Optimal Approach: First player wins iff .
- Complexity: Time: | Space:
- Edge Cases: (win immediately).
Q525: Fast Fourier Transform (FFT Polynomial Multiplication)
- Difficulty:
[Hard]| Pattern:[Divide & Conquer Complex Roots of Unity] - Statement: Multiply two degree- polynomials in time.
- Optimal Approach: Convert coefficients to Point-Value form via FFT using complex roots of unity . Multiply point values in . Inverse FFT back to coefficients in .
- Complexity: Time: | Space:
- Edge Cases: Zero polynomial, degrees not powers of 2 (pad with zeroes).
References & Academic Attribution
#- Skiena, S. S. (2020). The Algorithm Design Manual (3rd ed.). Springer.
- Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2022). Introduction to Algorithms (4th ed.). MIT Press.
- USA Computing Olympiad (USACO) & CP-Algorithms Archives (2024). Curated Competitive Programming and Algorithm Verification Standards.