tags:


4. Largest subrange and closest pair #

Created Tue Jul 30, 2024 at 12:14 AM

page 173-174

Largest subrange (aka max subarray sum) #

The block must be on the left, right or straddling-the-middle.

Note:

Closest pair #

Assume a number line with some points. We need to find a pair of points with the shortest distance.

So DnC is better here, O(n) and O(lgn), time and space.

This may seem insignificant for time, but the solution works for 2D as well, so it is significant.