Merge Time-Ordered Audit Logs From Multiple Mainframe LPARs

Last updated: November 29, 2026

Quick Overview

Each logical partition (LPAR) on an IBM Z system produces an audit log already sorted by timestamp; merge k such logs into one globally sorted list.

IBM
Coding & Algorithms
Software Engineer
IBM
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Each logical partition (LPAR) on an IBM Z system produces an audit log already sorted by timestamp; merge k such logs into one globally sorted list.

IBM Z customers in banking consolidate SMF and audit records across LPARs for compliance, so k-way merge is a natural phone-screen question for mainframe and security software teams. The interviewer wants a min-heap of size k rather than concatenating and sorting.

What the Interviewer Expects
  • Use a min-heap seeded with the head of each log
  • Push the next record from the same log after each pop
  • Break timestamp ties deterministically
  • State O(N log k) time
  • Mention streaming the output instead of materializing it
Key Topics to Cover
heap
k-way merge
priority queue
streaming
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 logs that do not fit in memory?
  • What if one LPAR's clock is skewed by a known offset?
  • How would you deduplicate records that appear in two logs?
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

Input: logs, a list of k lists, each a list of (timestamp, lpar, message) tuples sorted by timestamp. Output: one list sorted by timestamp, ties broken by the LPAR's index in the input so the resu...

High-Level Design

Concatenating and sorting costs O(N log N) and ignores that inputs are sorted. Instead keep a min-heap with one entry per log: (timestamp, log_index, position). Pop the smallest, emit it, and push t...


Submit Your Answer
Markdown supported