Adobe Interview Question

Related to trees and graphs ques were asked.