You are maintaining a codebase containing n methods labeled from n
You are given two integers n and k, and a invocations, where invocations[i]
A group of methods is identified as suspicious:
Method k is suspicious.
Any method directly or indirectly invoked by a suspicious method is also suspicious.
You want to remove all suspicious methods from the codebase. However, they can only be removed if no non suspicious method invokes any suspicious method. If at least one non suspicious method invokes a suspicious method, no methods can be removed.
Return a list containing the indices of all remaining methods. If the suspicious methods cannot be removed, return all n method indices. The list may be returned in any order.
Constraints:
n
k n
invocations.length
invocations[i]
n
invocations[i] invocations[j]
You are maintaining a codebase containing n methods labeled from n
You are given two integers n and k, and a invocations, where invocations[i]
A group of methods is identified as suspicious:
Method k is suspicious.
Any method directly or indirectly invoked by a suspicious method is also suspicious.
You want to remove all suspicious methods from the codebase. However, they can only be removed if no non suspicious method invokes any suspicious method. If at least one non suspicious method invokes a suspicious method, no methods can be removed.
Return a list containing the indices of all remaining methods. If the suspicious methods cannot be removed, return all n method indices. The list may be returned in any order.
Constraints:
n
k n
invocations.length
invocations[i]
n
invocations[i] invocations[j]