由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请教一个phone interview 问题
相关主题
google phone screen下周要去onsite了,求bless 顺便发些最近FLGAM的面经
常见的string hash function请教order irrelevant的string hashing
一道caeerCup上的难算法题问个问题binary search 的变体
湾区公司店面C++里做hashset的time complexity是多少?
F家电面:group Anagramsgoogle 一题
Phone Interview面经判断一个string是否是某个pattern的周期循环
Bloomberg, Amazon 面经,为onsite攒RP谷歌电面回馈
【什么时候需要做heap, 什么时候需要做BST】Reverse String 有 O(logn)的方法么?
相关话题的讨论汇总
话题: pool话题: string话题: table话题: interview话题: phone
进入JobHunting版参与讨论
1 (共1页)
w*****8
发帖数: 38
1
How would you estimate time complexity of an operation of adding a string
into the intern pool of unique strings? N is the size of the pool
我说是O(N), interviewer 说不对。 但不说为什么。
d**e
发帖数: 6098
2
pool是什么data structure?

【在 w*****8 的大作中提到】
: How would you estimate time complexity of an operation of adding a string
: into the intern pool of unique strings? N is the size of the pool
: 我说是O(N), interviewer 说不对。 但不说为什么。

c***2
发帖数: 838
3
http://en.wikipedia.org/wiki/String_interning
intern pool is just a hash table or count table
depending on how the table is stored:
0) hash table: O(1)
1) linear array: O(n)
2) heap/BST: O(logn)
w*****8
发帖数: 38
4

Actually before insert the string into the pool, it needs to search if
this string is existing or not; if not, the string will be added into the
pool, so I think it is O(N)

【在 c***2 的大作中提到】
: http://en.wikipedia.org/wiki/String_interning
: intern pool is just a hash table or count table
: depending on how the table is stored:
: 0) hash table: O(1)
: 1) linear array: O(n)
: 2) heap/BST: O(logn)

d**e
发帖数: 6098
5
depends on what data structure is pool is.
if it is hash table, O(1) search.
if sorted list, BST search takes O(lg n).
if unsorted list, it's O(n).

【在 w*****8 的大作中提到】
:
: Actually before insert the string into the pool, it needs to search if
: this string is existing or not; if not, the string will be added into the
: pool, so I think it is O(N)

h**6
发帖数: 4160
6
O(len(str)) If it's a trie.
c***2
发帖数: 838
7
That what it takes (to locate the position), insertion itself always takes O
(1)

【在 w*****8 的大作中提到】
:
: Actually before insert the string into the pool, it needs to search if
: this string is existing or not; if not, the string will be added into the
: pool, so I think it is O(N)

1 (共1页)
进入JobHunting版参与讨论
相关主题
Reverse String 有 O(logn)的方法么?F家电面:group Anagrams
攒rp,Amazon两轮电话面经Phone Interview面经
[合集] 今天面试惨败,分享面经Bloomberg, Amazon 面经,为onsite攒RP
Google 面题【什么时候需要做heap, 什么时候需要做BST】
google phone screen下周要去onsite了,求bless 顺便发些最近FLGAM的面经
常见的string hash function请教order irrelevant的string hashing
一道caeerCup上的难算法题问个问题binary search 的变体
湾区公司店面C++里做hashset的time complexity是多少?
相关话题的讨论汇总
话题: pool话题: string话题: table话题: interview话题: phone