Breadth-first Search (BFS)
690 Employee Importance This could be done either in DFS or BFS traversal of the graph. Both need a define a map to save the id to employee object pointer, so that we could easily get the subordinate employee info while traversing. For BFS, we use a deque<Employee*> since it is a super version of queue allowing us insert at both end of the queue. (1) push_back the mp[id] info into the queue (2) while the queue is not empty, do the following: pop_front the front element in the queue, add its importance to the the total importance of the employee id (either itself or its mangers'), push_back all its subordinate employee into the deque. (3) return the total importance in the end. Tree 107 Binary Tree Level Order Traversal II BFS: Define a queue (you could also use deque), push root in queue. loop each element while q is not empty, define a nextLevelStarter to keep track of the beginn...