Databricks Interview Question

graph question - traversal and hashmap and optimzation