Google interview question

Solve a graph and security level question (leetcode).