FastPrepStreaming Keyword Redaction
Problems/Streaming Keyword Redaction

Streaming Keyword Redaction

Google logoGoogle● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks to find and replace keywords in a file, with follow-ups for very large files and distributed chunks. We fixed exact, case-sensitive whole-word matching, and redaction of the same length that keeps the separators. Our version is about 77% the same as the reported question.

Given text and unique case-sensitive keywords, replace every keyword that appears as a complete word with the same number of * characters.

A word is a full run of consecutive ASCII letters, digits, or underscores, ending at any other character or the end of the text. Preserve every non-word character exactly. Substrings inside a larger word are not replaced.

Process the text in one left-to-right pass so the method can be adapted to a very large file.

Function

redactKeywords(text: String, keywords: String[]) → String

Examples

Example 1

text = "red blue redwood"keywords = ["red"]return = "*** blue redwood"

The standalone red is replaced, while the prefix inside redwood is preserved.

Example 2

text = "User_1,user_1!"keywords = ["user_1"]return = "User_1,******!"

Matching is case-sensitive and underscore is part of a word.

Example 3

text = ""keywords = ["secret"]return = ""

Empty text remains empty.

Constraints

  • 0 <= text.length <= 1000000.
  • 0 <= keywords.length <= 100000.
  • Each keyword is a nonempty ASCII word with length at most 100.
  • The total keyword length is at most 1000000.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Non-Repeating CharacterAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Container Ledger with TradesFlexport · ONSITE INTERVIEWFlexport interview questions
  • Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
  • Count a User's Actions in an Event LogMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
  • First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Minimum Replacements to Make Two Strings AnagramsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Logger Rate LimiterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Isomorphic StringsRemitly · ONSITE INTERVIEWRemitly interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String redactKeywords(String text, String[] keywords) {
        // Write your code here.
    }
}
Checking account…