Skip to content

Commit c3bd522

Browse files
authored
Update squares-of-a-sorted-array.cpp
1 parent d1819dc commit c3bd522

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

C++/squares-of-a-sorted-array.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
class Solution {
55
public:
66
vector<int> sortedSquares(vector<int>& A) {
7-
int right = 0;
8-
while (right < A.size() && A[right] < 0) {
9-
++right;
10-
}
7+
int right = distance(A.cbegin(), lower_bound(A.cbegin(), A.cend(), 0));
118
int left = right - 1;
12-
139
vector<int> result;
1410
while (0 <= left || right < A.size()) {
1511
if (right == A.size() ||

0 commit comments

Comments
 (0)