Skip to content

Commit 10a269f

Browse files
committed
Runtime: 13 ms (Top 55.08%) | Memory: 13.7 MB (Top 17.99%)
1 parent ec6e03d commit 10a269f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

scripts/algorithms/F/Find First and Last Position of Element in Sorted Array/Find First and Last Position of Element in Sorted Array.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
// Runtime: 13 ms (Top 55.08%) | Memory: 13.7 MB (Top 17.99%)
12
class Solution {
23
public:
3-
4+
45
int startEle(vector<int>& nums, int target,int l,int r)
56
{
67
while(l<=r)
@@ -18,10 +19,10 @@ class Solution {
1819
return m;
1920
}
2021
}
21-
22+
2223
return -1;
2324
}
24-
25+
2526
int lastEle(vector<int>& nums, int target,int l,int r)
2627
{
2728
while(l<=r)
@@ -39,11 +40,11 @@ class Solution {
3940
return m;
4041
}
4142
}
42-
43+
4344
return -1;
4445
}
4546
vector<int> searchRange(vector<int>& nums, int target) {
46-
47+
4748
vector<int> binSearch;
4849
int a = startEle(nums,target,0,nums.size()-1);
4950
if(a==-1)
@@ -56,11 +57,11 @@ class Solution {
5657
{
5758
binSearch.push_back(a);
5859
}
59-
60+
6061
int b = lastEle(nums,target,0,nums.size()-1);
6162
binSearch.push_back(b);
62-
63+
6364
return binSearch;
64-
65+
6566
}
66-
};
67+
};

0 commit comments

Comments
 (0)