leetcode 35 Search Insert Position(二分法)
2024-08-27 02:55:20
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You may assume no duplicates in the array.
Here are few examples.[1,3,5,6]
, 5 → 2[1,3,5,6]
, 2 → 1[1,3,5,6]
, 7 → 4[1,3,5,6]
, 0 → 0
很简单,没的说。
class Solution {
public:
int searchInsert(vector<int>& nums, int target) {
int ans=lower_bound(nums.begin(),nums.end(),target)-nums.begin();
return ans;
}
};
最新文章
- CentOS 7 防火墙 firewall 的使用
- Quartz2D简介
- BZOJ-1975 魔法猪学院 K短路 (A*+SPFA)
- JQuery中对Select的option项的添加、删除、取值
- 开源 java CMS - FreeCMS2.3 留言管理
- URAL 1553. Caves and Tunnels 树链拆分
- chapter8_3 c代码和错误
- nginx之 nginx + tomcat + redis 负载均衡且session一致性
- Hibernate学习笔记二
- SpringCloud的Hystrix(二) 某消费者应用(如:ui、网关)访问的多个微服务的断路监控
- 转-->;>;mysql的bin log
- hbase-0.92.1表备份还原
- 关于python的多行注释,启动新浏览器,循环语句乘法口诀
- jTimer
- java UCnter 单点登录 对接。
- DevExpress ASP.NET Bootstrap Controls v18.2新功能详解(一)
- 关于tomcat和sessionCookieName和SESSION_PARAMETER_NAME以及disableURLRewriting参数原理和使用
- spring @Bean注解解释
- Mongodb网络好文章
- jsoncpp 构造空数组
热门文章
- python 3 关于requests库的 text / content /json
- 闪屏Flash动画
- apple-touch-icon-precomposed 和 apple-touch-icon属性区别
- springmvc demo
- POJ 286 Y2K Accounting Bug【简单暴力】
- java高级主题
- JavaScript-Confirm用法
- 我的Android进阶之旅------>Android无第三方Jar包的源代报错:The current class path entry belongs to container ...的解决方法
- JVM相关的几个基本概念
- lua的弱弱引用表