Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Example 1 is wrong?

singhursefamily

Dec 11, 2025

It seems to me that the Example 1 expected output is not in alphabetical order.

Quoting from Example 1:

  • Input: Products: ["apple", "apricot", "application"], searchWord: "app"
  • Expected Output: [["apple", "apricot", "application"], ["apple", "apricot", "application"], ["apple", "application"]]

The problem is that "apricot" comes after "application" when sorted alphabetically since the third character of "apricot" is "r" while the third character of "application" is "p" and "r" comes after "p".

So the expected output should actually be: [["apple", "application", "apricot" ], ["apple", "application", "apricot" ], ["apple", "application"]].

Please correct me if I'm mistaken.

0

0

Comments
Comments