OctopusLian / leetcode-solutions

LeetCode,LintCode,牛客网,企业题库,《Sword to Offer》,《Cracking the Coding Interview》题解
MIT License
4 stars 4 forks source link

每日一题:手写代码:局部最小值问题。数组无序,相邻元素不等。如何求极小值? #208

Closed OctopusLian closed 2 years ago

OctopusLian commented 3 years ago

https://my.oschina.net/u/4553401/blog/4716354 二分法。有时候数组无序,同样可以采用二分法。这道题考察的是全局观,左边下降趋势,右边上升趋势,函数图像呈凹形,必有极小值。中左值和中值呈上升趋势,中值右边可以直接舍弃;中值和中右值呈下降趋势,中值左边可以直接舍弃。