Neighboring Record IDs
Updated
Problem statement
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.
More ZipRecruiter Phone Screen questions
- Restaurant Vote LeadersPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2026
- Most Frequent Word across Grouped ArraysPHONE SCREEN · Seen Sep 2024
- Starting Value with the Longest Collatz ChainPHONE SCREEN · Seen Apr 2022
- Classify an Alien Dictionary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
- Multiset Intersection of Three ListsPHONE SCREEN · Seen Feb 2022
- Find the Smallest Magic IndexPHONE SCREEN · Seen Dec 2021
- Website Pair with the Most Common VisitorsPHONE SCREEN · Seen Nov 2021
- Center-Outward Number SpiralPHONE SCREEN · Seen Jun 2021
- Missing Ranges within Inclusive BoundsPHONE SCREEN · Seen Feb 2021
- Fibonacci Number with Constant Extra SpacePHONE SCREEN · Seen Mar 2017
Similar questions at other companies
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- Most Frequent NameAmazon · PHONE SCREEN
- Words with Repeated AnagramsThe Voleon Group · PHONE SCREEN
- Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
- Product Keyword SearchTesco · PHONE SCREEN
- Verify Words Sorted by a Custom AlphabetTrueFoundry · PHONE SCREEN
- Character Frequencies Across Nested String ListsSnowflake · PHONE SCREENSnowflake interview questions