📝【LeetCode】一个模板通杀所有「二分查找」问题 #80
imageslr
announced in
Announcements
Replies: 2 comments
-
请问,这个计算mid的公式是不是有点问题,查了一下发现C++、Python、Java里面都是+号优先级大于位移,这样好像会造成死循环; |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi,感谢指正。我之前没有在 C++ 测试过。这种写法是 Golang 特有的,如果用在 C++ 确实会死循环。完善的写法应该是:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
https://imageslr.github.io/2020/03/15/binary-search.html
引言 二分查找有很多应用场景。可以说,只要问题对应的函数图像在给定区间是单调的,那就可以使用二分查找在这个区间搜索目标值。
Beta Was this translation helpful? Give feedback.
All reactions