当前位置:网站首页>不会就坚持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)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。边栏推荐
- 有一种密码学专用语言叫做ASN.1
- [untitled]
- 2021 sist summer camp experience + record post of School of information, Shanghai University of science and technology
- C语言:结构体简单语法总结
- When array is used as a function parameter, it is better to use the array size as a function parameter
- pat A1041 Be Unique
- Safari's compatibility with Z-index
- UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0x90 in position 614: ordinal not in range(128)
- Mmdetection preliminary use
- MPU6050
猜你喜欢

基于STM32和阿里云的环境检测系统设计

BGP的基础配置---建立对等体、路由宣告

Lua语言(stm32+2G/4G模块)和C语言(stm32+esp8266)从字符串中提取相关数据的方法-整理

从淘宝,天猫,1688,微店,京东,苏宁,淘特等其他平台一键复制商品到拼多多平台(批量上传宝贝详情接口教程)

力扣面试题17.04 消失的数字||260.只出现一次的数字(内含位运算知识点)

How to solve the problem of store ranking?

Function pointer and callback function

Blood cases caused by < meta charset=UTF-8> -- Analysis of common character codes

店铺排名问题,如何解决?

Data mining -- Introduction to the basis of association analysis (Part 1)
随机推荐
Nacos registry
Copy products with one click from Taobao, tmall, 1688, wechat, jd.com, Suning, taote and other platforms to pinduoduo platform (batch upload baby details Interface tutorial)
SVG--loading动画
Const char* and char*, string constants
当我从数据库获取到了winfrom特定的控件ID之后我需要通过这个ID找到对应的控件,并对控件的TEXT文本进行赋值这该怎么做
C语言:typedef知识点总结
安装postgis时报找不到“POSTGIS_VERSION”这个函数
[Openstack] keystone,nova
[deep learning CPU (part outside) - virtual memory]
(.*?) regular expression
编译与链接
"Weilai Cup" 2022 Niuke summer multi school training camp 2H
How to solve the problem of store ranking?
Class starts! See how smardaten decomposes complex business scenarios
Wechat applet monitors sliding events on the screen
When array is used as a function parameter, it is better to use the array size as a function parameter
[principle] several ways of horizontal penetration
路由 知识
BIO、NIO、AIO的区别和原理
Codeforces Round #810 (Div. 2) D. Rain (线段树差分)