认认真真刷Leetcode:Search Insert Posi
2019-11-20 本文已影响0人
Natsu想当科学家
Search Insert Position(插入索引位置)
难度:easy
题目描述:

解题思路:
这个题用简单的二分法即可以做到
但是有个坑,一定要注意:
if not ,return the index where it would be if it were inserted in order.
(如果这个值不存在,请返回该值要插入地方的数组坐标)
我连续错误两次 都是因为 我直接就返回return -1了
具体解法:

提交结果 通过