Kill Process


  • 0

    Click here to see the full article post


  • 0
    A

    The question is “Now given the two lists, and a PID representing a process you want to kill, return a list of PIDs of processes that will be killed in the end. You should assume that when a process is killed, all its children processes will be killed. No order is required for the final answer.” Are you sure the signature "public int findLHS(int[] nums)" is good for this question?


  • 0

    It seems mismatching answer and problem.


  • 0

    @mrvon @aprilyin Sorry there was some problem. We have fixed it. Thanks


  • 0
    A

    I was also thinking if it can be done like, find the node that needs to be killed. Then mark that with respect to its parent as null, (e.g. in this 5 is the node to be killed so mark 2's left to be null ) but save that tree in a temporary node, say temp. After that just traverse using one of the traversal and add the nodes to be printed in an array or list and print them. How about this?


  • 0
    A

    I feel like you should also mention that a simple topological sort from the 'kill' node generates the answer - particularly Approach #3 does basically just that.


  • 0
    D

    I think the time complexity for first approach is n^2, because there is no repetition nodes which are already explored during the search process.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.