Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
idk solution in Clear category for How to Find Friends by fishsouprecipe
from collections import defaultdict
def check_connection(network, first, second):
connections = defaultdict(set)
for connection in network:
c1, c2 = connection.split('-')
connections[c1].add(c2)
connections[c2].add(c1)
return recursive_find(connections, first, second)
def recursive_find(connections, where, find, *ignore):
if find in connections[where]:
return True
return any(recursive_find(connections, connection, find, *ignore, where) for connection in connections[where] if connection not in ignore)
March 8, 2020