Safi
BAN USER
Comments (6)
Reputation 20
Page:
1
2
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
"To prepare the array of strings, you just need to iterate on it and create an array of arrays by splitting each string by space" - I think array of sets would be better because if two words are the same then they are both valid or invalid.
Aside from this, I absolutely agree with the rest. That's a linear time algorithm. Asymptotically there is nothing better than this. No need for trie or whatever...
Page:
1
2
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- Safi November 27, 2014