关于左右边界的含义讨论 #689
casablancaml
started this conversation in
Ideas
关于左右边界的含义讨论
#689
Replies: 0 comments
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.
-
实际上可能不需要返回-1,具体地说看题目的要求。
这与左右边界的含义有关。到底什么是左右边界呢?就是这个 target 要插入这个有序数组的话,同时还维持数组有序,那么那个正确的插入位置就应该是所谓的左右边界。因此极端情况下,即使数组中不存在等于target的数,那么也应该返回0或者是nums.length,而不是-1。那么,在C++ STL的容器中,就采用的是这种含义。
Beta Was this translation helpful? Give feedback.
All reactions