space saving sketch implementation