Find the Root Process
Problem statement
processIds[i] is a process ID and children[i] lists its child process IDs. The rows are in arbitrary order and together form one rooted tree.
Return the root process ID.
Function
findRootProcess(processIds: int[], children: int[][]) → intExamples
Example 1
processIds = [5,1,4,3,6,2]children = [[],[2,3],[],[6],[],[4,5]]return = 1Every ID except 1 appears as a child.
Constraints
1 <= processIds.length <= 10^5.children.length == processIds.length.- Process IDs are unique and every child ID appears in
processIds. - The relationships form one rooted tree.