Sliding Window Algorithm With Variable Size