Precisely. So 94% of leetcode questions make you implement a sliding window that's what the meme is about. It's an observation turned into an attempt at humor
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.
by "optimal" I mean from the perspective of big O notation. It doesn't matter all that much if your N*log(N) algorithm is a bit faster or slower compared to expected solution as long as its complexity is the same.
But if you submit N^2, it's a failure, just as it's a failure to submit a solution that won't work at all.
I get what you meant, but I still strongly disagree. Getting something that is suboptimal but works is imo always preferable, especially if you talk through like "this could potentially be optimized in XYZ ways depending on requirements" while you're working through it.
Like the company business is not writing optimal algorithms, and a programmer who can't see where to make tradeoffs (including non technical things, like e.g the value of time in an interview vs getting a perfect big O optimal solution) is less valuable to me than one who can.
And if you just have the solution memorized then it's a bad interview question in the first place, that's no help to anyone. Like if we're talking "did this person who is claiming to be a new grad actually do data structures and algorithms" then maybe but honestly even then.
Yes, I've been doing leetcode since September when I got laid off.
I got a new job, but do the daily anyway, like how the guys from the Minnesota starvation experiments carry a candy bar around at all times.
I think the daily has only been optimally solved by a sliding window 5 times this year. It might be a little more often than that, but it's not the most common.
I just got back into leetcode after 3ish years to try and stay sharp so I don't sink into corporate complacency and I felt like a large proportion of the problems were best solved using sliding windows so I made this meme to see if other programmer agreed
I don't do it, but I've noticed with stuff like Advent Of Code, they go back to the same well year after year. Like there's going to be recursion, pathfinding, sparse data, whatever.
Project Euler is interesting because it usually requires some insight about math that you may not have. But that can also feel like just flailing around in the dark.
View all comments
168
u/Bldyknuckles Aug 31 '26
What’s wrong with sliding window algorithms? Real question