Find the Best Word for a Query Suffix
Company: Bytedance
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
Quick Answer: Practice a Bytedance coding interview problem focused on find the best word for a query suffix. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.
Examples
Input: {"words":["time","me","bell"],"queries":["mime"]}
Expected Output: ["time"]
Explanation: Tie suffix length, shorter wins.
Input: {"words":["abc","xbc","zz"],"queries":["qbc"]}
Expected Output: ["abc"]
Explanation: Tie length and size, lexicographic.
Input: {"words":["a","b"],"queries":["x"]}
Expected Output: ["a"]
Explanation: No suffix tie.
Input: {"words":[],"queries":["x"]}
Expected Output: [""]
Explanation: No words.
Input: {"words":["running","jogging","king"],"queries":["sing"]}
Expected Output: ["king"]
Explanation: Longest suffix ing.
Input: {"words":["hello"],"queries":["hello"]}
Expected Output: ["hello"]
Explanation: Exact.
Input: {"words":["car","bar","far"],"queries":["star","zz"]}
Expected Output: ["bar","bar"]
Explanation: First by lexicographic when tied.
Input: {"words":["abcd","bcd","cd"],"queries":["xxcd"]}
Expected Output: ["cd"]
Explanation: Shortest among equal suffix.