About This Book
Programming Challenges and Algorithmic Puzzles
What Lies Ahead
Meet the Authors
Meet Our Online Co-Instructors
Acknowledgments
Algorithms and Complexity
What Is an Algorithm?
Pseudocode
Problem Versus Problem Instance
Correct Versus Incorrect Algorithms
Fast Versus Slow Algorithms
Big-O Notation
Algorithm Design Techniques
Exhaustive Search Algorithms
Branch-and-Bound Algorithms
Greedy Algorithms
Dynamic Programming Algorithms
Recursive Algorithms
Divide-and-Conquer Algorithms
Randomized Algorithms
Programming Challenges
Sum of Two Digits
Maximum Pairwise Product
Naive Algorithm
Fast Algorithm
Testing and Debugging
Can You Tell Me What Error Have I Made?
Stress Testing
Even Faster Algorithm
A More Compact Algorithm
Solving a Programming Challenge in Five Easy Steps
Reading Problem Statement
Designing an Algorithm
Implementing an Algorithm
Testing and Debugging
Submitting to the Grading System
Good Programming Practices
Algorithmic Warm Up
Fibonacci Number
Last Digit of Fibonacci Number
Greatest Common Divisor
Least Common Multiple
Fibonacci Number Again
Last Digit of the Sum of Fibonacci Numbers
Last Digit of the Sum of Fibonacci Numbers Again
Greedy Algorithms
Money Change
Maximum Value of the Loot
Maximum Advertisement Revenue
Collecting Signatures
Maximum Number of Prizes
Maximum Salary
Divide-and-Conquer
Binary Search
Majority Element
Improving QuickSort
Number of Inversions
Organizing a Lottery
Closest Points
Dynamic Programming
Money Change Again
Primitive Calculator
Edit Distance
Longest Common Subsequence of Two Sequences
Longest Common Subsequence of Three Sequences
Maximum Amount of Gold
Partitioning Souvenirs
Maximum Value of an Arithmetic Expression
Appendix
Compiler Flags
Frequently Asked Questions