Neighboring Record IDs
Reported by candidates from ZipRecruiter's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure is the whole question here. ZipRecruiter's Neighboring Record IDs problem, reported in May 2026, hands you a list of strings like "a|red" and a pile of queries, and asks for each id's previous and next neighbor. It looks like string parsing, but the real work is lookup. If you scan the list once per query, you're doing it the slow way. Build a hash map from id to index and answer every query in constant time. If you blank on the setup during the live OA, StealthCoder is the safety net running invisibly on your screen.
The problem
You are given records in their current order. Each record is a string whose id appears before the first | character. For each queried id, return the previous and next record ids in the original order. The answer for one query should be formatted as previousId,nextId. Use None for a missing neighbor or for both values when the queried id is not present. Function queryNeighborIds(records: String[], queries: String[]) → String[] Examples Example 1 records = ["a|red","b|blue","c|green","d|yellow"] queries = ["a","c","x"] return = ["None,b","b,d","None,None"] a has no previous id, c is between b and d, and x is not present. Example 2 records = ["id7|one"] queries = ["id7"] return = ["None,None"] A single record has no neighbors. Constraints Record ids are unique.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Parse each record by taking everything before the first | character. That's your id. Ids are unique, so you can build a map from id to its index in one pass. Then for each query, look up the index. If it's missing, output "None,None". Otherwise the previous id is the parsed id at index-1 (or None if index is 0), and the next id is at index+1 (or None if it's the last). Store the parsed ids in a separate array so you don't re-split strings per query. The common pitfall is splitting on every | and grabbing the wrong piece, or using a linear search per query and timing out on large inputs. Another one: a record value may itself contain a | character, so only cut at the first one. Output format is previousId,nextId with a comma and no space. StealthCoder is the hedge if the format details slip under pressure.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Neighboring Record IDs cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass ZipRecruiter's OA.
ZipRecruiter reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Neighboring Record IDs FAQ
What's the trick in Neighboring Record IDs?+
Build a hash map from id to index once, plus an array of parsed ids. Each query then becomes an index lookup and a check of index-1 and index+1. No repeated scanning, no sorting. Total work is linear in records plus queries.
How hard is this ZipRecruiter OA question really?+
Easy. It's a parsing and lookup problem with no tricky algorithm. The points are lost on edge cases: first record, last record, single record, and ids that aren't present. Handle those four and you're done.
How do I extract the id from a record?+
Take the substring before the first | character. Use an index-of call and slice, not a full split, because the value part after the pipe could contain more pipes. Splitting and taking element zero also works, but slicing is safer.
What should I output for a missing id or a missing neighbor?+
If the id isn't in the records, return "None,None". If it exists but is first, the previous is None. If it's last, the next is None. Always format as previousId,nextId with a single comma and no spaces.
How do I prepare for this in 48 hours?+
Practice hash map index lookups and string slicing in your language of choice. Write this one from scratch twice, including the edge cases. That's enough. The pattern is simple, so speed and clean handling of None cases matter most.