Merge Object Track Fragments With Must-Differ Constraints
Last updated: November 29, 2026
Quick Overview
A perception pipeline produces n track fragments. Given pairs asserted to be the same object and pairs asserted to be different objects, return whether the assertions are consistent, how many distinct objects remain, and the first violated must-differ pair.
Applied Intuition
November 29, 20260
0
0 solved
A perception pipeline produces n track fragments. Given pairs asserted to be the same object and pairs asserted to be different objects, return whether the assertions are consistent, how many distinct objects remain, and the first violated must-differ pair.
Applied Intuition builds tools for labeling and validating perception output, where re-identification across occlusions creates exactly these merge assertions. The interviewer checks union-find with path compression and union by rank, plus a clear way of reporting contradictions.
What the Interviewer Expects
- Use a disjoint set union with path compression and union by rank
- Track the component count as unions succeed
- Apply all same-object merges before checking must-differ pairs
- Return the first conflicting pair for debugging
- State near-constant amortized time per operation
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- What if assertions arrive one at a time and you must reject the first contradictory one?
- How would you support undoing a merge a labeler marked as wrong?
- How would you weight assertions by confidence and pick a consistent subset?
- How do you list the fragment ids in each identity?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Fragments are integers 0..n-1. same and different are lists of pairs. Output (consistent, identity_count, first_conflict). Order matters only for which conflict is reported....
High-Level Design
Same-object assertions are transitive, so they define connected components: a DSU is the natural fit. After all merges, any must-differ pair whose endpoints share a root is a contradiction. Checking a...
Submit Your Answer
Applied Intuition Software Engineer Interview Guide
Interview process, tips, and preparation timeline