flexport 最新电面 第二轮 面经

5081
9
flexport实习电面, 45min, 一共一道题, 有个follow up。面试的小哥好像是个华人, 但是口语非常好, 可能是很早就来美国的那种。

Given a string, implement a method that given a word in the sentence, randomly return one of its following words. Plus, if the given wrod is in the end of the string, the first word is counted as
its following word.

解答: 写了一个hashmap, key is every word in the string, value is a list of word that follows it.

Follow up: given a substring of the sentence, return the next words of the substring.

解答: 我本来想要用Trie做的, 但是发现 space complexity 太高了, 经面试官提醒, 改成用substring作为hashmap的key。但是implementation 有点麻烦, 特别是包含最后一个word到第一个word的情况, 所有最后也没有写完。

不设积分限制了, 希望小天使们给我加点大米。 有问题我会回复的。
  • 7
9条回复