← Discussions on Shortest Subarray With Sum ≥ Target
V vikram_36 OFFICIAL
31 Aug 2026, 18:35

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.

2 replies

manish.k 1 month, 2 weeks ago

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

neha_75 1 month, 1 week ago

Watch out for integer overflow in Java on the large test.

Sign in to reply.