Count connected land components in a grid | LinkedIn Interview Question