Pergunta de entrevista da empresa Airbnb

Count all ancestors in a directed graph. O(n) time/space