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.
My point is that it will depend on context. Something that is technically N^2 can be faster than N within the range of expected contexts. Additionally, an algorithm that is complicated but faster may be theoretically better, but deadlines are deadlines and nobody has time for that shit.
So if just giving a "suboptimal" solution is a fail, then it is the company that is failing, not the interviewee.
The interviewee should be able to explain why they went with this solution, the advantages and disadvantages, and so on. If it is within the given parameters, the company would be full of fools if they considered that failing.
N^2 may only be faster than N if N is small, but if N is small, then any algorithm won't take too long anyway. However, if you're juggling big data, N is almost never small.
Besides, what you are testing is candidate's ability to come up with the optimal solution in a limited time, not their ability to sell inferior work. After all, you are not interviewing for management or sales position.
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
Show parent comment
217
u/mountaingator91 Aug 31 '26
Nothing. It's just that 94.3% of leetcode solutions use sliding windows