Legacy Code

From programming_contest
Jump to navigation Jump to search

This problem gives us a list of function names and the functions that CALL those functions and asks, given the top-level set of functions we know are called, how many listed functions are not reached?

This is a typical BFS problem. Simply build an adjacency list as you read the input and then BFS from any function which matches the regex "::Program$". Return the count of unreached functions. Ensure to deal with the case of having zero or multiple "program" functions.