← 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 2 months, 3 weeks ago

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

manishtiwari 2 months, 3 weeks ago

This should be marked as the editorial approach honestly.

vamsi.t 2 months, 3 weeks ago

This should be marked as the editorial approach honestly.

Sign in to reply.