FastPrepFilter Words Containing a Letter
Problems/Filter Words Containing a Letter

Filter Words Containing a Letter

Shopify logoShopify● EasyINTERNOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The core filtering task matches the report at about 95%. Input bounds and the rules for order, repeated words, and lowercase letters are practice assumptions.

Given a list of words words and one letter letter, return every word that contains that letter at least once.

For this exercise, assume the words and letter use lowercase English letters. Keep the original word order and keep repeated words. Include a matching word only once for each occurrence in the input, even when the letter appears several times in that word.

Function

filterWords(words: String[], letter: String) → String[]

Examples

Example 1

words = ["apple","pear","banana","kiwi"]letter = "a"return = ["apple","pear","banana"]

apple, pear, and banana contain a. kiwi does not. The matching words keep their input order.

Example 2

words = ["","book","book","sky"]letter = "o"return = ["book","book"]

Both occurrences of book are retained. Its two o letters do not add extra copies. The empty word and sky do not match.

Constraints

  • 0 <= words.length <= 1000
  • 0 <= words[i].length <= 100
  • letter.length == 1
  • Every word and letter contains only lowercase English letters.

More Shopify problems

  • Deterministic Secret Santa AssignmentPHONE SCREEN · Seen Oct 2026
  • Mars Rover Robot ControllerPHONE SCREEN · Seen Oct 2026
  • Choose Items for a BackpackOA · Seen May 2026
All Shopify interview questionsSee Shopify hiring insights
Saved
public String[] filterWords(String[] words, String letter) {
    // Write your code here.
}
Checking account…