The Find Words Containing Character interview question is a fundamental string filtering task. You are given an array of strings (words) and a single character (x). Your task is to return a list of the indices of all words in the array that contain the character x.
Companies like Meta and Amazon use this as a very basic screening question. It tests a candidate's familiarity with Array and String iteration. It evaluations if you can correctly traverse a data structure and use built-in string methods (like contains or find) to perform a search. It’s an essential "level zero" coding task.
This problem follows the Linear Scan pattern.
words array from index 0 to .x is present.x, you can stop searching that word and move to the next index.words = ["apple", "banana", "cherry"], x = 'a'
[0, 1].Even for simple problems, focus on Code Readability. Use descriptive variable names and clear loop structures. Interviewers use these easy questions to see your "natural" coding style and attention to detail.