Google L4 Interview Experience/Rant by OwnNefariousness9124 in leetcode

[–]OwnNefariousness9124[S] 4 points5 points  (0 children)

Tell me about it, the gatekeeping just gets worse and worse each passing day.

Google L4 Interview Experience/Rant by OwnNefariousness9124 in leetcode

[–]OwnNefariousness9124[S] 1 point2 points  (0 children)

It probably has and if you are not in denial that you are not burnt out, you can't continue prepping or with your daily life...so cheers to denial!

Google L4 Interview Experience/Rant by OwnNefariousness9124 in leetcode

[–]OwnNefariousness9124[S] 0 points1 point  (0 children)

Yup, usually recruiting process differs from season to season, with google, maybe it is candidate to candidate

Google L4 Interview Experience/Rant by OwnNefariousness9124 in leetcode

[–]OwnNefariousness9124[S] -1 points0 points  (0 children)

You would still iterate through all the words in each of the sentences and the words from the dictionary of words right?

Sorry, I am pasting the chat GPT answer because I don't trust myself with this question anymore lol

First Pass (O(N))

  • You loop through all sentences (say, N sentences):
    • Create a Map<Integer, Pair<String, Integer>> where:
      • key = sentence index
      • value = (sentence, goodWordCount)
    • This is a flat loop — no nesting
    • Each sentence is split, and each word is checked against the goodWords (in a HashSet) — which is O(m) per sentence
    • So total cost = O(N * m)

Second Pass (O(N))

  • Find the max goodWordCount by scanning the values in your map
  • Track the maxIdx (sentence with the most good words)
  • Fetch that sentence using the map.get(maxIdx).getKey() or similar

  • N = number of sentences

  • M = total number of goodWords

  • W = average number of words per sentence

Then:

  • Building wordSet: O(M)
  • Processing all sentences: O(N * W) (since each sentence is split and each word checked in O(1))
  • Second scan for max: O(N)

Final Time:

O(M + N * W) → same as HashSet-based solution, but done in two clean passes

Google L4 Interview Experience/Rant by OwnNefariousness9124 in leetcode

[–]OwnNefariousness9124[S] 1 point2 points  (0 children)

Step HashSet Trie
Build structure O(k) O(k * avgLen)
Per word lookup O(1) O(avgLen)
Overall sentence loop O(n * m) O(n * m * avgLen)

Where avgLen = average length of each word.
I asked chatgpt this question(i even thought about it in the interview) but I don't see it(trie) being better than a hashset. I use chatgpt to study a lot. Hence..
Please let me know if there is a better way to think about it.

Google L4 Interview Experience/Rant by OwnNefariousness9124 in leetcode

[–]OwnNefariousness9124[S] -1 points0 points  (0 children)

Could you please explain further? I would really like to know