LinkedIn Interview Question

Find the number of connected components