https://srkmzbtkmpoff.blogspot.com/2021/07/how-to-find-local-maximum-and-minimum.html