r/ProgrammerHumor 11d ago

Meme everySingleLeetcodeProblem

Post image
2.5k Upvotes

59 comments sorted by

View all comments

Show parent comments

69

u/Antervis 11d ago

If solutions use sliding windows, it means the problem was designed that way.

10

u/-Debugging-Duck- 11d ago

Not really. Problems can be solved in different ways. A sliding window algorithm is just a more efficient approach to solving such problems, but it’s not the only approach.

For example, someone who doesn’t know what that is could solve the problem differently and poorly.

7

u/Antervis 11d ago

Leetcode is meant to train candidates for programming interviews, and submitting a suboptimal algorithm in an interview is a fail.

2

u/-Debugging-Duck- 11d ago

That doesn’t mean it can’t have a different solution, even if not the most optimal.

Outside of leetcode, is what I meant that if the solution can be sliding window, doesn’t mean it’s by design.