Click here to see the full article post
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?
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?
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.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.