Merge Two Sorted Transaction Linked Lists Without Duplicates

Last updated: November 29, 2026

Quick Overview

Two upstream feeds deliver card transactions as singly linked lists sorted by (timestamp, transaction id), and some transactions appear in both. Merge them into one sorted list in place, keeping a single copy of each shared transaction.

Capital One
Coding & Algorithms
Software Engineer
Capital One
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Two upstream feeds deliver card transactions as singly linked lists sorted by (timestamp, transaction id), and some transactions appear in both. Merge them into one sorted list in place, keeping a single copy of each shared transaction.

Capital One ingests the same transactions from more than one source (network files and real-time authorization streams), so merges with de-duplication come up in data plumbing. On the assessment this checks pointer manipulation with a dummy head and comparing composite keys correctly.

What the Interviewer Expects
  • Use a dummy head to avoid special-casing the first node
  • Compare on the full (timestamp, id) key
  • Advance both lists when the keys are equal
  • Attach the remaining tail in one step
  • Reuse nodes with O(1) extra space
Key Topics to Cover
Linked lists
Two pointers
Merge step
De-duplication
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you merge k feeds instead of two?
  • What if a duplicate can have a slightly different timestamp in the two feeds?
  • How would you de-duplicate within a single feed as well?
  • How would you do this with Python iterators instead of linked lists?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Each list is sorted ascending by (ts, txn_id); within one feed, ids are unique.
  • A shared transaction has identical ts and txn_id in both feeds.
  • Return the head of the merged list with each tra...
High-Level Design

This is the merge step of merge sort with one extra case. Keep a dummy node and a tail pointer. Compare the heads' keys: smaller goes next; if they are equal, link one copy and advance both lists, whi...


Submit Your Answer
Markdown supported