Small hint to get O(n)

interview-questions
Tags: #<Tag:0x00007f181abe7560>

#1

Think like DFS with hashing to get an O(n) solution.