Legacy Code

From programming_contest
Revision as of 07:30, 25 September 2018 by Kmk21 (talk | contribs) (Created page with "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 f...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.