Your question is Find Cyclic Dependency. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given a set of tuples, identify if there is a cyclic dependency.
Treat each tuple (a, b) as a directed dependency from a to b. Implement has_cyclic_dependency(dependencies), which returns True if any directed cycle exists and False otherwise. Nodes may appear only as dependency targets, and disconnected components must also be checked.
Examples: [("A", "B"), ("B", "C")] returns False; [("A", "B"), ("B", "A")] returns True.
def has_cyclic_dependency(dependencies):