Grumpy Bookstore Owner Solutions Guide C/C++ Sliding window technique Linear time Dynamic programming C# No explanation, but readable code Java Sliding window technique One pass, sliding window technique JavaScript Two pass, sliding window technique 98% faster and 100% less memory Python Detailed explanation Sliding window technique Ruby No solution found on Leetcode. I recommend looking at cpp solution or java solution to understand how to solve.