Hi,
While we are creating the whole graph and doing DFS to find out connected components. This question can be easily solved with O(1) space and a single iteration.
The idea is to mark all the chars in a string as a single component. If they were previously part of any component just connect to that component. It is something similar to Disjoint data set(union find). I tried it and it was accepted on codeforces. The code is in Java.
Maybe the current solution video could be improved. Or at least this approach could be discussed in the video.