How do you approach learning new algorithms or data structures?
For the hands-on portion, implement a function that turns prerequisite relationships into a valid learning order. Return every topic once, after all of its prerequisites, or return an empty list when the prerequisites contain a cycle.
Input: a list of topic names and pairs [topic, prerequisite].
Output: a list of topic names in valid learning order, or [] if no such order exists.
def learning_order(topics, prerequisites):