Amazon Online Assessment 2021 (OA) - Grid Connections

A supply chain manager at Amazon Logisitcs wants to determine the number of connections between warehouses, represented as nodes on a grid. A grid with m rows and n columns is used to form a cluster of nodes. If a point in the grid has a value of 1, then it represents a node.


This is a companion discussion topic for the original entry at https://algo.monster/problems/amazon-oa-grid-connections/