c#, simple DFS solution.
204 ms, faster than 100.00% of C# online submissions\n\n\npublic class Solution {\n    public int MakeConnected(int n, int[][] connections) {\n        \n       
**204 ms, faster than 100.00% of C# online submissions**\n\n```\npublic class Solution {\n    public int MakeConnected(int n, int[][] connections) {\n        \n        if(connections.Length < n - 1){\n            return -1;\n        }\n     \n        Dictionary<int, List<int>> connectionsAsMap = BuildMapFromArray(connections);\n        bool[] visited = new bool[n];\n        int count = -1;\n        \n        for(int visitedIndex = 0; visitedIndex < n; visitedIndex++){\n            if(!visited[visitedIndex]){\n                DFS(visitedIndex, connectionsAsMap, visited);\n                count++;\n            }\n        }\n        \n        return count;\n    }\n    \n    private void DFS(int source, Dictionary<int, List<int>> connectionsAsMap, bool[] visited){\n        \n        visited[source] = true;\n        \n        List<int> connectionAdjacents = connectionsAsMap.ContainsKey(source) ? connectionsAsMap[source] : new List<int>();\n        \n        foreach(int connectionAdjacent in connectionAdjacents){\n            \n            if(!visited[connectionAdjacent]){\n                DFS(connectionAdjacent, connectionsAsMap, visited);\n            }\n        }\n    }\n    \n    private Dictionary<int, List<int>> BuildMapFromArray(int[][] connections){\n        \n        Dictionary<int, List<int>> result = new Dictionary<int, List<int>>();\n        \n        foreach(int[] connection in connections){\n            \n            if(!result.ContainsKey(connection[0])){\n                result.Add(connection[0], new List<int>());\n            }\n            \n            if(!result.ContainsKey(connection[1])){\n                result.Add(connection[1], new List<int>());\n            }\n            \n            result[connection[0]].Add(connection[1]);\n            result[connection[1]].Add(connection[0]);\n        }\n        \n        return result;\n    }\n}\n```
['Depth-First Search', 'C']