Techniques for optimizing nested-loop solutions into linear time or linear time into logarithmic time.