[刷题]Search Insert Position
来源:互联网 发布:p2p网络监控软件 编辑:程序博客网 时间:2024/06/14 19:47
[LintCode]Search Insert Position
public class Solution { /** * param A : an integer sorted array * param target : an integer to be inserted * return : an integer */ public int searchInsert(int[] A, int target) { // 2015-4-7 binary search if (A == null || A.length == 0) { return 0; } int start = 0; int end = A.length - 1; while (start + 1 < end) { int mid = (start + end) / 2; if (A[mid] >= target) { end = mid; } else { start = mid; } } if (A[start] >= target) { return start; } else if (A[end] >= target) { return end; } else { return end + 1; } }}
0 0
- [刷题]Search Insert Position
- 弱渣leetcode刷题-Search Insert Position
- LeetCode刷题【Array】Search Insert Position
- LeetCode-Easy刷题(10) Search Insert Position
- LeetCode: Search Insert Position
- Search Insert Position
- LeetCode Search Insert Position
- [Leetcode] Search Insert Position
- LeetCode : Search Insert Position
- Search Insert Position
- [LeetCode] Search Insert Position
- [Leetcode] Search Insert Position
- LeetCode34:Search Insert Position
- Search Insert Position
- [35]Search Insert Position
- Search Insert Position
- Search Insert Position
- [LeetCode]Search Insert Position
- java多线程总结(转)
- JAVA:使用HTTP的get()方法来实现网络数据的读取
- Hinton关于RBM的代码注解之(三)mnistclassify.m
- [笔记] How to get the versionCode and versionName of your app
- Android Eclipse 项目报错,但没有显示具体错的代码位置
- [刷题]Search Insert Position
- Mac下面的SecureCRT(附破解方案) 更新到最新的7.3.2
- 代理模式
- 动态规划
- androidの调用系统相机拍照
- 转自66RPG:NeoAxis教程 第一篇,从头开始
- poj 2142 The Balance(不定方程)
- 查看ipc资源情况及其删除共享内存命令
- android振动效果的实现