← Discussions on Intersection of Two Arrays
T tkumar OFFICIAL
06 Aug 2026, 06:42

Why does my solution TLE on the last test case?

A single pass with a running value is enough here. Keep track of the best answer so far and update it as you scan, which gives O(n) time and O(1) extra space.

2 replies

pooja.m 2 months, 1 week ago

Nice. Got asked a variant of this in an interview.

harini.p 2 months ago

This should be marked as the editorial approach honestly.

Sign in to reply.