Count islands on a torus grid | TikTok Interview Question