Skip to content

Commit 57b09cd

Browse files
authored
Update shortest-subarray-with-or-at-least-k-i.cpp
1 parent f82b0c8 commit 57b09cd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

C++/shortest-subarray-with-or-at-least-k-i.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ class Solution2 {
5656
for (int left = 0; left < size(nums); ++left) {
5757
for (int right = left, curr = 0; right < size(nums); ++right) {
5858
curr |= nums[right];
59-
if (curr >= k) {
60-
result = min(result, right - left + 1);
61-
break;
59+
if (curr < k) {
60+
continue;
6261
}
62+
result = min(result, right - left + 1);
63+
break;
6364
}
6465
}
6566
return result != INF ? result : -1;

0 commit comments

Comments
 (0)