FastPrepWord Search Across Documents
Problems/Word Search Across Documents

Word Search Across Documents

Confluent logoConfluent● EasyFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Firsthand reports ask for the document numbers that contain a word, followed by phrase search. One says clearly that a single preprocessed store must serve both word and phrase queries. We chose lowercase tokens, document IDs that start at zero, sorted output with no repeats, the examples, and the limits. The older reports do not say whether the words of a phrase must be next to each other. Our version is about 86% the same as the reported questions.

Given an array of text documents and a query word, return the zero-based indices of all documents that contain the query as a complete word.

Words are lowercase English-letter tokens separated by one space. Matching is exact: a query does not match part of a longer token. Include each matching document index once, in increasing order.

Follow-up: one reusable index

Preprocess the document collection once, then use the same data structure for repeated single-word and phrase queries. Explain how storing each word's document IDs and positions supports both operations without rebuilding or maintaining a separate index for each query form.

Documents may have explicit document numbers. Here, the array index is the document number; in a service, retain the external document number in each posting. Your function only does the single-word lookup. For phrase practice, try the companion sequential phrase-search problem.

Function

findDocumentsWithWord(documents: String[], word: String) → int[]

Examples

Example 1

documents = ["red blue green","bluebird flies","green blue"]word = "blue"return = [0,2]

Documents 0 and 2 contain token blue. Token bluebird is not an exact match.

Example 2

documents = ["alpha beta","gamma delta","alpha"]word = "omega"return = []

No document contains the token omega.

Constraints

  • 1 <= documents.length <= 1000.
  • 1 <= documents[i].length <= 1000.
  • 1 <= word.length <= 50.
  • Every document contains lowercase English words separated by exactly one space, with no leading or trailing space.
  • word contains only lowercase English letters.

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
  • Build an Inverted Document IndexONSITE INTERVIEW · Seen Sep 2026
  • Combination Sum with Unlimited ReuseONSITE 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

  • Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Bounded Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions
  • Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
  • Parse and Sort Integer DataLegora · PHONE SCREEN
  • Longest Common Parent DirectoryGoogle · ONSITE INTERVIEWGoogle interview questions

Interview reports that mention this question

  • Confluent SWE OA, Coding and Design Interviews: 19 Experiences
  • Confluent Coding and System Design Questions: 33 Questions

Confluent interview experiences

  • Confluent Older Concurrency Rounds: 12 Experiences (Part 2 of 2)
  • Confluent Concurrency Interviews: 28 Experiences (Part 1 of 2)
  • Confluent File Manipulation Round (tail -n): 19 Experiences
All Confluent interview questionsSee Confluent hiring insights
Saved
class Solution {
    public int[] findDocumentsWithWord(String[] documents, String word) {
        // write your code here
    }
}
Checking account…