Click here to see the full article post
Good solution, but I think for the DSU, we don't have to initiate 10001 integers, we could just build the data structure on the fly. check out mine, welcome all comment.
@alicia.lihong It is accepted in Python (Python 2). In Python 3, please use
self.p = list(range(10001)) to create the list.
I don't get how to come up with the time complexity of the approach #2. Can someone give me a hint? Why is that different from the approach #1?
@zc94zc it uses user space stack to implement DFS.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.