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.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.