FastPrepFastPrep
Problem Brief

Neighboring Record IDs

FULLTIMEPHONE SCREEN

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.

1Example 1

Input
records = ["a|red","b|blue","c|green","d|yellow"], queries = ["a","c","x"]
Output
["None,b","b,d","None,None"]
Explanation

a has no previous id, c is between b and d, and x is not present.

2Example 2

Input
records = ["id7|one"], queries = ["id7"]
Output
["None,None"]
Explanation

A single record has no neighbors.

Constraints

Limits and guarantees your solution can rely on.

Record ids are unique.

public String[] queryNeighborIds(String[] records, String[] queries) {
    // write your code here
}
Input

records

["a|red","b|blue","c|green","d|yellow"]

queries

["a","c","x"]

Output

["None", "b", "b", "d", "None", "None"]

Sign in to submit your solution.