当前位置:网站首页>leetcode 35. Search insert location
leetcode 35. Search insert location
2022-06-12 06:22:00 【Well, let me see】
35. Search insert location 
Thought analysis :
Dichotomous template question .
AC Code :
class Solution {
public:
int searchInsert(vector<int>& nums, int target) {
if(nums.size() == 1) {
if(nums[0] < target) return 1;
else return 0;
}
int l = 0, r = nums.size() - 1;
while(l < r) {
int mid = (l + r) >> 1;
if(nums[mid] >= target) r = mid;
else l = mid + 1;
}
if(nums[r] < target)
return r + 1;
else
return r;
}
};
边栏推荐
- [reinstall system] 01 system startup USB flash disk production
- (UE4 4.27) customize globalshader
- Logistic regression model
- Leetcode-1705. Maximum number of apples to eat
- Open the camera in unity3d and display the contents of the camera in the scene as texture2d
- Multithreading (2) -- pipeline (2) -- synchronized underlying monitor, lightweight, biased lock, lock inflation
- cv2.fillPoly coco annotator segment坐标转化为mask图像
- Script for unity3d to recursively search for a node with a specific name from all child nodes of a node
- Une explication du 80e match bihebdomadaire de leetcode
- Opencv_100问_第五章 (21-25)
猜你喜欢

Houdini script vex learning

Nodemon cannot load the file c:\users\administrator\appdata\roaming\npm\nodemon PS1, because script execution is prohibited in this system

BRDF of directx11 advanced tutorial PBR (2)

Leetcode-1535. Find the winner of the array game

Redis queue

Leetcode-1043. Separate arrays for maximum sum

UE4 4.27 modify the mobile forward pipeline to support cluster multi light source culling

Using hidden Markov model to mark part of speech

Bulk Rename Utility

2D human pose estimation for pose estimation - pifpaf:composite fields for human pose estimation
随机推荐
【思维方法】之第一性原理
Multithreading mode (I) -- protective pause and join source code
Tips for using the potplayer video player
Unity3d display FPS script
Solution to the problem of the 80th fortnight competition of leetcode
哈工大信息内容安全实验
Piecewise Bezier curve
Opencv_ 100 questions_ Chapter V (21-25)
Why don't databases use hash tables?
Leetcode-93. Restore IP address
Jetson TX2 machine brushing jetpack4.2 (self test successful version)
Redis configuration (III) -- master-slave replication
Unity3d script captures a sub area from the screen and saves it as texture2d, which is used to save pictures and maps
N-degree Bessel curve
Android studio mobile development creates a new database and obtains picture and text data from the database to display on the listview list
Nodemon cannot load the file c:\users\administrator\appdata\roaming\npm\nodemon PS1, because script execution is prohibited in this system
UE4 4.27 modify the mobile forward pipeline to support cluster multi light source culling
sqlite交叉編譯動態庫
cv2.fillPoly coco annotator segment坐标转化为mask图像
Unity custom translucent surface material shader