Google interview question
Check whether two sequences can be merged without duplicates while keeping order
- Company:
- Type:
- Coding
- Difficulty:
- Medium
- Reported:
- November 16, 2026
Problem
You are given two integer sequences. Determine whether they can be merged into a single sequence that contains no duplicate numbers while preserving the relative order of the numbers within each original sequence. A number that appears in both sequences appears once in the merged result, so it must sit at a position consistent with both orders.
Return true if such a merged sequence exists, otherwise false.
Example 1
Input: a = [1, 2, 15, 8], b = [2, 4, 7, 8]
Output: true
For example [1, 2, 15, 4, 7, 8] keeps 1 before 2 before 15 before 8, and 2 before 4 before 7 before 8.
Example 2
Input: a = [1, 2], b = [2, 1]
Output: false
The first sequence needs 1 before 2 and the second needs 2 before 1.
Constraints
- Not stated; ask the interviewer.
Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern