Implement topological sort from string input | Netflix