当前位置:网站首页>不会就坚持64天吧 查找插入位置
不会就坚持64天吧 查找插入位置
2022-07-29 04:13:00 【一只小小明】

class Solution {
public int searchInsert(int[] nums, int target) {
int n = nums.length;
int left = 0, right = n - 1, ans = n;
while (left <= right) {
int mid = ((right - left) >> 1) + left;
if (target <= nums[mid]) {
ans = mid;
right = mid - 1;
} else {
left = mid + 1;
}
}
return ans;
}
}
作者:LeetCode-Solution
链接:https://leetcode.cn/problems/N6YdxV/solution/cha-zhao-cha-ru-wei-zhi-by-leetcode-solu-inlw/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。边栏推荐
- 不会就坚持65天吧 只出现一次的数字
- Codeforces Round #810 (Div. 2) D. Rain (线段树差分)
- Rhel8 patch package production
- Beginner: array & String
- Who can elaborate on the semi consistent read under mysqlrc and how to reduce the deadlock probability?
- 小程序:区域滚动、下拉刷新、上拉加载更多
- Install the laser of ROS_ scan_ Problems encountered in match library (I)
- HCIP BGP
- 淘宝商品详情接口(商品详情页面数据接口)
- MySQL Part 3
猜你喜欢

初识C语言(3)

How to solve the problem of store ranking?

Mmdetection preliminary use

不会就坚持69天吧 合并区间

HCIP BGP

AssertionError(“Torch not compiled with CUDA enabled“)

Object array merges elements according to a field
![[paper translation] vectornet: encoding HD maps and agent dynamics from vectorized representation](/img/4b/150689d5e4809ae66a4297915ecd0c.png)
[paper translation] vectornet: encoding HD maps and agent dynamics from vectorized representation

2021 sist summer camp experience + record post of School of information, Shanghai University of science and technology

STM32F103ZET6程序移植为C8T6+C8T6下载程序flash timeout的解决方案
随机推荐
SQL server how to judge when the parameter received by the stored procedure is of type int?
请问为什么我进行mysql数据update时,kafka中采集到的是先删除原纪录(op d)再新增新
C language to achieve three chess game (detailed explanation)
不会就坚持69天吧 合并区间
Code or script to speed up the video playback of video websites
店铺排名问题,如何解决?
Beginner: array & String
The function "postgis_version" cannot be found when installing PostGIS
SQL server当存储过程接收的参数是int类型时,如何做判断?
[kvm] create virtual machine from kickstart file
Pointer of pointer???...
Is there any way for Youxuan database to check the log volume that the primary cluster transmits to the standby cluster every day?
对一个元素使用多种变形的方法
BIO、NIO、AIO的区别和原理
Data mining -- code implementation of association analysis example (Part 2)
MySQL Part 3
After I get the winfrom specific control ID from the database, I need to find the corresponding control through this ID and assign a value to the text text of the control. What should I do
Summary on the thought of double pointer
JS realizes the function of one click Copy
顺序表和链表