FastPrepAdd Word and Suffix Search
Problems/Add Word and Suffix Search

Add Word and Suffix Search

Anduril logoAnduril● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Anduril full-time onsite interview. The report asks for Add Word plus Suffix Search. It points to reversing the input and using a trie. We chose how the operations come in, the true or false result, how duplicates work, and what an empty suffix does.

You are given two arrays of the same length, operations and values. Go through them from left to right. Each operation is one of:

  • add: store the lowercase word at the same position in values. Adding a word that is already stored does not change any later answer.
  • search: the entry at the same position in values is a suffix to look for. Append true to the result if at least one stored word ends with the whole suffix. Otherwise append false.

An empty suffix matches when at least one word has already been added, and does not match otherwise. Return one Boolean for every search operation, in the order the operations appear.

Function

suffixSearch(operations: String[], values: String[]) → boolean[]

Examples

Example 1

operations = ["add","add","search","search","add","search"]values = ["apple","maple","ple","xyz","happy","py"]return = [true,false,true]

The first two words, apple and maple, both end in ple, so the first search gives true. No stored word ends in xyz, so the second search gives false. Then happy is added. It ends in py, so the last search gives true. The result is [true,false,true].

Example 2

operations = ["search","add","search","add","search"]values = ["","code","","code","de"]return = [false,true,true]

The first search uses an empty suffix before any word is added, so it gives false. After code is added, the empty suffix matches, so the second search gives true. Adding code again changes nothing. The stored word code ends in de, so the last search gives true. The result is [false,true,true].

Constraints

  • operations.length == values.length.
  • 1 <= operations.length <= 200000.
  • Every operation is "add" or "search".
  • Added words are non-empty strings of lowercase English letters. Suffixes are strings of lowercase English letters and may be empty.
  • The sum of all word and suffix lengths is at most 500000.

More Anduril interview questions

  • Binary Tree Preorder TraversalONSITE INTERVIEW · Seen Aug 2026
  • Operator-First Array CalculatorONSITE INTERVIEW · Seen Aug 2026
  • Daily TemperaturesONSITE INTERVIEW · Seen Jun 2024
  • Highlighted Context WindowsONSITE INTERVIEW · Seen Jun 2024
  • Pacific Atlantic Water FlowPHONE SCREEN · Seen Aug 2026
  • Choose the Front Football TeamPHONE SCREEN · Seen May 2026
  • Maximum Visible DronesPHONE SCREEN · Seen Jun 2024
  • Build a Sorted Circular Singly Linked ListPHONE SCREEN · Seen Feb 2024
  • Sparse Vector Dot ProductPHONE SCREEN · Seen Apr 2021

Similar questions at other companies

  • Word Dictionary with Wildcard FindAmazon · ONSITE INTERVIEW
  • Implement a TrieMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Trie: Add and Search WordsAdobe · ONSITE INTERVIEWAdobe interview questions
  • Implement TrieRoblox · ONSITE INTERVIEWRoblox interview questions
  • In-Memory Directory and File OperationsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • File System PathsCapital One · ONSITE INTERVIEWCapital One interview questions
  • Implement TrieBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Trie With Insert, Search and Prefix CheckExpedia · ONSITE INTERVIEWExpedia interview questions
  • Design File SystemGoogle · PHONE SCREENGoogle interview questions
  • Implement TrieOptiver · PHONE SCREENOptiver interview questions
All Anduril interview questionsSee Anduril hiring insights
Saved
class Solution {
    public boolean[] suffixSearch(String[] operations, String[] values) {
        // Write your code here.
    }
}
Checking account…