← Discussions on Shortest Subarray With Sum ≥ Target
S shrutisha8 OFFICIAL
07 Sep 2026, 04:45

Why does my solution TLE on the last test case?

The answer space is monotonic, so binary search on it. Be careful with the loop condition (lo < hi vs lo <= hi) and how you move the bounds.

3 replies

mchatterjee 1 month, 1 week ago

Great explanation, the edge case with an empty input tripped me up too.

manishtiwari 1 month, 1 week ago

This should be marked as the editorial approach honestly.

vamsi.t 1 month, 1 week ago

This should be marked as the editorial approach honestly.

Sign in to reply.