Solve string dictionary and tree ordering
BloombergSoftware Engineer · Technical ScreenLast updated
This question evaluates design and analysis skills for string-matching data structures that support one-edit queries and for binary tree traversal with coordinate-based ordering, testing understanding of data structures, search algorithms, sorting, and complexity analysis within the Coding & Algorithms domain.
Part A — One-edit dictionary: Build a data structure supporting build(words: List[str]) and search(query: str) -> bool that returns true if and only if there exists a stored word obtainable by changing exactly one character of query. Discuss possible designs (e.g., trie with masked patterns or hash-based buckets), edge cases (length mismatches, duplicates, non-lowercase), and complexity. Part B — Tree ordering by coordinates: Given a binary tree whose nodes contain lowercase letters, assign coordinates with root at (row=0, col= 0), left child at (row+1, col- 1), and right child at (row+1, col+ 1). Output the concatenation of node values ordered by column ascending, then row ascending; break ties left-to-right. Describe an algorithm (e.g., DFS/BFS to collect (row, col, char) then stable sort) and analyze time and space complexity.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.