Google Phone Screening for L4

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-06-12Added By Anonymous
Source: Link

Company: Google
Role: L4
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

1st Round - Phone Screening

After initial introductions,
The interviewer gave me a piece of code and told me to write the expected output from that code.
It was a simple code comparing characters from two strings, and if the characters were not matching, it was returning the index.
He then asked me to name the function, which I did.

This was followed with a DSA question:
Given a dictionary of words and a target word, return true if the target word can be formed from prefix and suffix of words in dictionary.
e.g.: dictionary: {"frog", "hat"}
targetWord -> frot, return true since fro from word 1 (which is prefix) and t from word 2 (which is suffix) satisfy the condition.

I told the brute force approach, in which we can check every string and if some prefix matches, we then go on to match suffix.
He asked me the TC and SC of this solution and after that asked what other approaches I can think of.

I suggested a 2nd Approach with Trie DS: we could store every word of dictionary in Trie and can then check for the targetWord.
We would need to create 2 tries: 1st prefixTree and 2nd as suffixTree.
He asked me the TC and SC of this approach and asked when would you go for the first approach and when for the second.
My answer was: for this particular question we can go ahead with the 1st approach, but if we have a stream of target words, we can then move ahead with the Trie approach since it would only take O(targetWordLength) to match that word in Trie.
He was satisfied with the answer and told me to code the 1st approach.
I did code it, but I think it had some bugs which he pointed out in the feedback, but overall the round was positive and I was selected for onsite interviews.

Comments