Find the Root Process
Updated
Problem statement
Given processIds and children, return the ID of the root process. processIds[i] is a process ID, and children[i] lists the IDs of its child processes.
The rows can be in any order. Together they form one rooted tree, and the root is the only process that is not anyone's child.
Function
findRootProcess(processIds: int[], children: int[][]) → intExamples
Example 1
processIds = [5,1,4,3,6,2]children = [[],[2,3],[],[6],[],[4,5]]return = 1Every other ID appears in some child list, so 1 is the only process with no parent.
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.
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Sum All Values in a Binary TreeDuolingo · PHONE SCREENDuolingo interview questions
- Sum Root-to-Leaf Binary NumbersOracle · PHONE SCREENOracle interview questions
- Decode a Bit String With a Code TreeGoogle · ONSITE INTERVIEWGoogle interview questions
- Symmetric Binary TreeDocuSign · PHONE SCREENDocuSign interview questions
- Lowest Common Ancestor in an Inserted BSTAmazon · PHONE SCREEN
- Maximum Depth of Binary TreeLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
- Maximum Value in a Binary TreeAkuna Capital · PHONE SCREENAkuna Capital interview questions
- Path SumSalesforce · ONSITE INTERVIEWSalesforce interview questions
- First Common Ancestor with Parent PointersMeta · PHONE SCREENMeta interview questions
- Binary Tree Level-Order Traversal by LevelsAdobe · PHONE SCREEN · ONSITE INTERVIEWAdobe interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)