Implement distinct islands and sliding maxima | TikTok Interview Question