Solve island and frequency problems | Meta Coding Question