Created
July 28, 2019 17:31
-
-
Save kanrourou/8999aa46355cb912408b19928ed23801 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int searchInsert(vector<int>& nums, int target) { | |
int len = nums.size(), lo = 0, hi = len; | |
while (lo < hi) { | |
int mid = lo + (hi - lo) / 2; | |
if (nums[mid] < target) | |
lo = mid + 1; | |
else | |
hi = mid; | |
} | |
return lo; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment