AKUNA CAPITAL interview question

Coding: number of connected components