由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - facebook telephone interview from careercup
相关主题
F家电面:group AnagramsAnagrams有面试碰到过么?
careercup 150一题。 9.2linkedin 电面题目
问一个 String array sorting 的题。请问我写的这个代码哪可以改进一下
google phone interviewBloomerg 还没放弃我。 电话二面经过。
问一个Anagram的参考程序[a9面经] print x,y,z
仅存onsite一只。。。散尽家财求bless问个anagram的题目啊
请教2个 huge file的面试题CS algorithm question
Google 需要bug free 么?问个anagram的问题
相关话题的讨论汇总
话题: anagrams话题: collection话题: string话题: careercup话题: telephone
进入JobHunting版参与讨论
1 (共1页)
l*********y
发帖数: 142
1
given a Collection words, return a Collection of anagrams
found in the given collection for example "The rat fell in the tar" =>
returned [rat tar]
Requirement:
O(n k lg k) where n is the number of words and k is the average length of
the word
sorting is O(n k lg k) , then in order to how all anagrams, how to make it
under
O(n k lg k) ?
Thanks!
g*********s
发帖数: 1782
2

anagrams
why "the", "fell" not in the collection? so single occurrences are
excluded?
of
it

【在 l*********y 的大作中提到】
: given a Collection words, return a Collection of anagrams
: found in the given collection for example "The rat fell in the tar" =>
: returned [rat tar]
: Requirement:
: O(n k lg k) where n is the number of words and k is the average length of
: the word
: sorting is O(n k lg k) , then in order to how all anagrams, how to make it
: under
: O(n k lg k) ?
: Thanks!

l*********y
发帖数: 142
3

The question wants to find all pairs of anagrams.

【在 g*********s 的大作中提到】
:
: anagrams
: why "the", "fell" not in the collection? so single occurrences are
: excluded?
: of
: it

a******7
发帖数: 106
4
use hash table, map each character to a primer number, and therefore each
word to sum, then it can be finished in O(n*k)
g*********s
发帖数: 1782
5
what do "all pairs" mean? say, if u have abc, bca, cab, then there are
totally 3 pairs...

【在 l*********y 的大作中提到】
:
: The question wants to find all pairs of anagrams.

l*****a
发帖数: 14598
6
你是要返回collection>的
否则多个怎么办?

anagrams
of
it

【在 l*********y 的大作中提到】
: given a Collection words, return a Collection of anagrams
: found in the given collection for example "The rat fell in the tar" =>
: returned [rat tar]
: Requirement:
: O(n k lg k) where n is the number of words and k is the average length of
: the word
: sorting is O(n k lg k) , then in order to how all anagrams, how to make it
: under
: O(n k lg k) ?
: Thanks!

l*********y
发帖数: 142
7

The question is not originally from me, but I guess triplet should be
considered as
one set of anagrams.
anson627
use hash table, map each character to a primer number, and therefore each
word to sum, then it can be finished in O(n*k)
is it easy to implement this idea on white board?
How to store the product of prime number? If it is a large number, I think
it is linear to the size of character. Then the multiplication takes k^2
time.

【在 g*********s 的大作中提到】
: what do "all pairs" mean? say, if u have abc, bca, cab, then there are
: totally 3 pairs...

j*****u
发帖数: 1133
8
use a hash table: Dictionary>
where key is sorted string, value is all strings equal to key after sorting
1st go thru all words, sort them and insert into the hash table
then go thru each value of hash table which contains the anagrams

【在 l*********y 的大作中提到】
:
: The question is not originally from me, but I guess triplet should be
: considered as
: one set of anagrams.
: anson627
: use hash table, map each character to a primer number, and therefore each
: word to sum, then it can be finished in O(n*k)
: is it easy to implement this idea on white board?
: How to store the product of prime number? If it is a large number, I think
: it is linear to the size of character. Then the multiplication takes k^2

1 (共1页)
进入JobHunting版参与讨论
相关主题
问个anagram的问题问一个Anagram的参考程序
一道G家店面题仅存onsite一只。。。散尽家财求bless
google面经请教2个 huge file的面试题
LC anagrams题目有问题吧?Google 需要bug free 么?
F家电面:group AnagramsAnagrams有面试碰到过么?
careercup 150一题。 9.2linkedin 电面题目
问一个 String array sorting 的题。请问我写的这个代码哪可以改进一下
google phone interviewBloomerg 还没放弃我。 电话二面经过。
相关话题的讨论汇总
话题: anagrams话题: collection话题: string话题: careercup话题: telephone