Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Node Disconnected Users by David_Jones
def disconnected_users(net, users, source, crushes):
connected = set()
crushes = set(crushes)
if source not in crushes:
G = {u:set() for u in users}
for u, v in net:
if u not in crushes and v not in crushes:
G[u].add(v)
G[v].add(u)
stack = [source]
while stack:
u = stack.pop()
connected.add(u)
for v in G[u]:
if v not in connected:
stack.append(v)
return sum(users[u] for u in users if u not in connected)
May 3, 2019