Implement a debounce function | Apple Interview Question