Microsoft Interview Question

Depth first search, hashmap(worst-case complexity)