ESRI INDIA Hiring | Number of Matrix using graphs | 2023

Question · Posted Jun 2026

Problem Statement There are n cities represented by an n × n adjacency matrix isConnected. isConnected[i][j] = 1 indicates that city i and city j are directly connected. isConnected[i][j] = 0 indicates no direct connection. A province is a group of directly or indirectly connected cities, with no connections to cities outside the group. Your task is to determine the total number of provinces. Example 1 Input isConnected = [  [1,1,0],  [1,1,0],  [0,0,1] ] Output 2 Explanation City 0 and ...

The full answer & interview discussion are available to premium members.

Log in Create a free account