Redian新闻
>
能有人详细讲一下这两道google的面试题吗?
avatar
能有人详细讲一下这两道google的面试题吗?# Programming - 葵花宝典
s*e
1
The first one: Write the code using an optimization algriothm to calcuate
the
intersection and union of two sets. (30 mins)
The second one: Write the code for an algriothm to transfrom the index in
excel to the number, and write a class to call this function without
declearing an object. for example: "A, B, C,....AB,AC,..BA,BB,....AAA,AAB,..
."
, transform to "1,2,3,.....", and also transform back.(30 mins)
avatar
r*g
2
avatar
g*g
3

sort two sets individually, merge
O(mlogm) + O(nlogn)
..
base 26 radix, no difference from converting back/forward binary to integer
just change 2 to 26

【在 s*********e 的大作中提到】
: The first one: Write the code using an optimization algriothm to calcuate
: the
: intersection and union of two sets. (30 mins)
: The second one: Write the code for an algriothm to transfrom the index in
: excel to the number, and write a class to call this function without
: declearing an object. for example: "A, B, C,....AB,AC,..BA,BB,....AAA,AAB,..
: ."
: , transform to "1,2,3,.....", and also transform back.(30 mins)

avatar
r*g
4
1.two ways:
(1) hash.
(2)sort first.
Two array A and B, Let array C to store the intersection of A and B
after sorting A and B.Let m be the size of A, n be the size of B.
i=0,j=0;
while(i{
if(A[i]< B[j]) i++;
if(A[i]>B[j]) j++;
else
{
add A[i] to C;
i++;j++;
}
}
then the union is A-C+B;
Time complexity maximum(O(mlogm),O(nlogn))
2.this is 26-based numbers. You should convert between 10-based numbers and
26-based numbers. Simulation is ok.
to call
avatar
p*u
5

yes, static method should be what they asked for.
avatar
c*z
6
for question two, how about make the function static and just
call in this way:
object:func()?

【在 r********g 的大作中提到】
: 1.two ways:
: (1) hash.
: (2)sort first.
: Two array A and B, Let array C to store the intersection of A and B
: after sorting A and B.Let m be the size of A, n be the size of B.
: i=0,j=0;
: while(i: {
: if(A[i]< B[j]) i++;
: if(A[i]>B[j]) j++;

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。