Fast algorithm for finding local extrema with minimal distance constraint