File tree 1 file changed +3
-6
lines changed 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change 10
10
// / Time Submitted: 06/22/2021 00:07
11
11
// /
12
12
13
- class Solution {
14
- public:
15
13
int search (vector<int >& nums, int target) {
16
14
return binary_search_ex (move (nums), target, 0 );
17
15
}
18
16
19
- int binary_search_ex (vector<int > nums, int target, int offset) {
17
+ int binary_search_ex (vector<int > && nums, int target, int offset) {
20
18
int ret = -1 ;
21
19
int len = nums.size ();
22
20
int mid = len / 2 ;
@@ -33,10 +31,10 @@ class Solution {
33
31
34
32
if (target < nums[mid]) {
35
33
std::vector<int > vec (nums.begin (), nums.begin () + mid);
36
- ret = binary_search_ex (vec, target, 0 );
34
+ ret = binary_search_ex (move ( vec) , target, 0 );
37
35
} else if (target > nums[mid]) {
38
36
std::vector<int > vec (nums.begin () + mid, nums.end ());
39
- ret = binary_search_ex (vec, target, mid);
37
+ ret = binary_search_ex (move ( vec) , target, mid);
40
38
} else {
41
39
return mid + offset;
42
40
}
@@ -54,4 +52,3 @@ class Solution {
54
52
55
53
return ret + offset;
56
54
}
57
- };
You can’t perform that action at this time.
0 commit comments