Kill Process
Problem statement
pid[i] is a process ID and ppid[i] is its parent ID; parent ID 0 denotes a root.
Killing process kill also kills every descendant. Return all killed process IDs in ascending order.
Function
killProcess(pid: int[], ppid: int[], kill: int) → int[]Examples
Example 1
pid = [1,3,10,5]ppid = [3,0,5,3]kill = 5return = [5,10]Process 10 is a child of 5.
Example 2
pid = [1,2,3]ppid = [0,1,1]kill = 1return = [1,2,3]Killing the root kills both children.
Constraints
pid.length == ppid.length.- Process IDs are unique and relationships form a forest.
killappears inpid.