Flag Repeated Transaction IDs Within a Batch Window
Last updated: November 29, 2026
Quick Overview
Given a list of transaction IDs from a mainframe batch feed and an integer k, return the indices where an ID repeats an earlier occurrence that is at most k positions back.
IBM
November 29, 20260
0
0 solved
Given a list of transaction IDs from a mainframe batch feed and an integer k, return the indices where an ID repeats an earlier occurrence that is at most k positions back.
IBM's online assessments for entry and associate software roles often start with a hashing warm-up framed around enterprise data such as banking batch feeds processed on IBM Z. The grader checks that you reach for a hash map of last-seen positions instead of a nested scan.
What the Interviewer Expects
- Clarify whether the window is inclusive of distance k
- Use a dictionary of last-seen index per ID
- Return all flagged indices in order, not just a boolean
- Achieve O(n) time
- Handle k of zero and empty input
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
- How would you do this if the feed is too large to hold the dictionary, but k is small?
- What changes if you must flag both members of each duplicate pair?
- How would you handle IDs that differ only by case or trailing spaces from fixed-width COBOL records?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: a list ids of strings and an integer k >= 0. Output: every index j such that some i < j has ids[i] == ids[j] and j - i <= k. A batch feed from an IBM Z job may contain retried trans...
High-Level Design
Walk the list once and keep a dictionary from ID to the most recent index where it was seen. Only the most recent index matters: if the latest occurrence is more than k back, any older one is even f...