Amazon Interview Question

Calculated how many connected components in a grid.