We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1344863 + 731dda9 commit 966bb31Copy full SHA for 966bb31
91/binary-search.md
@@ -562,6 +562,25 @@ public class BinarySearch {
562
}
563
```
564
565
+##### C++
566
+
567
+```cpp
568
+public:
569
+ int binarySearch(int* arr, int arrLen,int a) {
570
+ int left = 0;
571
+ int right = arrLen - 1;
572
+ while(left<=right)
573
+ {
574
+ int mid = (left+right)/2;
575
+ if(arr[mid]>=a)
576
+ right = mid - 1;
577
+ else
578
+ left = mid + 1;
579
+ }
580
+ return left;
581
582
+```
583
584
其他语言暂时空缺,欢迎
585
[PR](https://github.com/azl397985856/leetcode-cheat/issues/4)
586
0 commit comments