Amazon Interview Question

the LC high frequency problem (using dfs or bfs)