class Solution {
public:
void dfs(vector<vector<int>>& isConnected, map<int, bool>& visited, int j, int n){
visited[j] = true;
for(int i = 0; i < n; i++){
if(isConnected[j][i] == 1 && visited[i] == false)
dfs(isConnected, visited, j, n);
}
}
int findCircleNum(vector<vector<int>>& isConnected) {
// visit city and increment provice count
// find neighbouring cities using DFS , add to each city to visited list and exit
int count = 0;
map<int, bool>visited;
int n = isConnected.size();
for(int i = 0; i < n; i++){
if(visited[i] == false){
count++;
dfs(isConnected, visited, i, n);
}
}
return count;
}};
When I execute the code follows, the error info showed like this.
Finished in N/A
AddressSanitizer:DEADLYSIGNAL
Dont understand what is wrong