News for hackers. Stuff that matters.
Re:On a Great Interview Question by whiddershins on Wednesday April 12, 2023 @11:50PM (#35550712)
T isn’t a word, next

Th isn’t a word, next

The is a word, look up ‘reis’, not a word, next

Ther isn’t a word, next

There is a word, look up ‘is’ it is a word, return true

If you don’t want to ignore whitespace, than I’m not sure what behavior you want, you want “there is” to return false?

If whitespace is the delimiter the whole thing is trivial, you split on space.

I am now more confused.

Re:On a Great Interview Question by the_af on Wednesday April 12, 2023 @11:54PM (#35550735)
> The is a word, look up ‘reis’, not a word, next

This is where the wrong greedy solution from TFA, which the author claims some candidates reach, stops. So it's wrong.

Note that if you do not stop, and continue as in your own example, your solution isn't "greedy"!

Re:On a Great Interview Question by behdad on Wednesday April 12, 2023 @11:55PM (#35550742)
That is a correct solution. The one I was talking about would stop after just trying "The" and "reis".
Re:On a Great Interview Question by whiddershins on Wednesday April 12, 2023 @11:59PM (#35550763)
Ok
Re:On a Great Interview Question by roflyear on Thursday April 13, 2023 @12:07PM (#35557631)
This guy has a massive ego. Glad I do not work at Google.
Re:On a Great Interview Question by whiddershins on Thursday April 13, 2023 @07:54AM (#35554034)
Anyway, don’t you get a savings by using some data structure that indexes the dictionary by word length first?

Or at least sorting by.