Build an Inverted Document Index
Updated
Problem statement
Build an inverted index for an ordered array of documents. Tokenize each document into maximal ASCII letter-or-digit terms, lowercase every term, and associate it with the zero-based IDs of documents containing it.
Return one string per term in ascending term order using term:id1,id2,.... Document IDs are ascending and appear at most once per term.
Function
buildInvertedIndex(documents: String[]) → String[]Examples
Example 1
documents = ["Red blue red","blue green"]return = ["blue:0,1","green:1","red:0"]Each term receives one posting per containing document in document order.
Example 2
documents = ["A a A"]return = ["a:0"]Each term receives one posting per containing document in document order.
Example 3
documents = []return = []Each term receives one posting per containing document in document order.
Constraints
0 <= documents.length <= 10000.- The total input length is at most
10^6. - Documents contain printable ASCII characters.
Source note: Author-written prompt excerpt retained for source fidelity.
More Confluent Onsite Interview questions
- Implement tail -nPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Sudoku Board ValidationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Sudoku Puzzle SolverPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Sequential Phrase Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Bounded Combination Sum with Signed CandidatesONSITE INTERVIEW · Seen Oct 2026
- Detect a Silent SensorONSITE INTERVIEW · Seen Sep 2026
- Combination Sum with Unlimited ReuseONSITE INTERVIEW · Seen Sep 2026
- Word Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Windowed Key-Value MapPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
- Get Best PriceONSITE INTERVIEW · Seen Apr 2025
Similar questions at other companies
- Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- Longest Consecutive Login StreakAmazon · ONSITE INTERVIEW
- Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
- Serialize and Deserialize a String Key-Value StoreByteDance · ONSITE INTERVIEWByteDance interview questions
- Group AnagramsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Most Frequent Call Stack Per ThreadRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
- Find Duplicate Element PairsGoogle · ONSITE INTERVIEWGoogle interview questions
- Filesystem Hash TreeCursor · PHONE SCREEN · ONSITE INTERVIEWCursor interview questions
- Sort Characters by FrequencySnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
Confluent interview experiences
- Confluent Older Concurrency Rounds: 12 Experiences (Part 2 of 2)
- Confluent Concurrency Interviews: 28 Experiences (Part 1 of 2)
- Confluent SWE OA, Coding and Design Interviews: 19 Experiences
- Confluent File Manipulation Round (tail -n): 19 Experiences
- Confluent Coding and System Design Questions: 33 Questions