Skip to content

Commit f7fc331

Browse files
authored
Update create-sorted-array-through-instructions.cpp
1 parent 40fa4a9 commit f7fc331

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

C++/create-sorted-array-through-instructions.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ class Solution_TLE {
117117
while (r <= mid && (*idxs)[r].first <= (*idxs)[i].first) {
118118
tmp.emplace_back((*idxs)[r++]);
119119
}
120-
tmp.emplace_back((*idxs)[i]);
120+
if (r <= mid) {
121+
tmp.emplace_back((*idxs)[i]);
122+
}
121123
(*counts)[(*idxs)[i].second] += mid - r + 1;
122124
}
123125
while (r <= mid) {

0 commit comments

Comments
 (0)