Redian新闻
>
G家电面面经【已过HC,求祝福啊】
avatar
G家电面面经【已过HC,求祝福啊】# JobHunting - 待字闺中
l*h
1
上上周五去MTV onsite的,这周一HR说HC已经过了,等这周EC省材料,下周给我消息。
希望不要在最后一步出啥问题吧。
电面题目:
一位国人大哥,先在这里谢过啦,时间刚好45分钟,吐槽下Google docs上写程序好蛋
疼,什么时候可以搞个可以支持Vim的编辑器吧。。。。
Assume some binary (each pixel is either black or white ) images, have same
width and height, and the length is power of 2. Present it by quadtree:
divide the image into quarters, each quarter can be all back, all white or
mixed, subdivide the mixed ones… recurse.
+-------+---+---+
| | F | F |
| T +---+---+
| | T | T |
+---+---+---+---+
| F | T | |
+---+---+ F |
| F | T | |
+---+---+-------+
a) how to present this image
struct TreeNode {
TreeNode* upperLeft;
TreeNode* downLeft;
TreeNode* upperRight;
TreeNode* downRight;
int size;
bool pixel;
TreeNode(bool p, int s): pixel(p), size(s), upperLeft(NULL), downLeft(
NULL), upperRight(NULL), downRight(NULL){}
};
TreeNode* copy( TreeNode* root) {
if( !root)
return NULL;
TreeNode* r = new TreeNode( root->pixel, root->size);
r->upperLeft = copy( root->upperLeft);
r->upperRight = copy( root->upperRight);
r->downLeft = copy( root->downLeft);
r->downRight = copy( root->downRight);
return r;
}
b) count all the black pixels of this image
int getBlackPixels( TreeNode* root) {
if(!root)
return 0;
if( !root->upperLeft) {
if( root->pixel)
return root->size * root->size;
}
int sum = 0;
sum += getBlackPixels( root->upperLeft);
sum += getBlackPixels( root->downLeft);
sum += getBlackPixels( root->upperRight);
sum += getBlackPixels( root->downRight);
return sum;
}
c) merge two image( actually it's to "and" two image with same size since
all pixels are boolean)
TreeNode* merge( const TreeNode* image1, const TreeNode* image2) {
if( !image1->upperLeft && !image2->upperLeft) {
return new TreeNode(image1->pixel && image2->pixel, image1->size);
}
if( !image1->upperLeft) {
return mergeHelper(image1, image2);
}
if( !image2->upperLeft) {
return mergeHelper(image2, image1);
}
TreeNode* root = new TreeNode(image1->pixel, image1->size);
root->upperLeft = merge( image1->upperLeft, image2->upperLeft);
root->upperRight = merge( image1->upperRight, image2->upperRight);
root->downLeft = merge( image1->downLeft, image2->downLeft);
root->downRight = merge( image1->downRight, image2->downRight);
return root;
}

TreeNode* mergeHelper( TreeNode* image1, TreeNode* image2) {

if( !image1->pixel) {
return new TreeNode(image1->pixel, image1->size);
}
return copy(image2);
}
Onsite因为签了NDA,所以就不多说了吧,遇到两个白人,一个国人大姐,一位阿三,
感谢国人大姐的放水。
avatar
s*9
2
con~~ 希望一切顺利
avatar
e*0
3
cong~ bless~~~
avatar
f*e
4
Bless! 肯定没问题的!
avatar
c*e
5
bless
avatar
u*o
6
bless!!
avatar
l*u
7
bless

same

【在 l***h 的大作中提到】
: 上上周五去MTV onsite的,这周一HR说HC已经过了,等这周EC省材料,下周给我消息。
: 希望不要在最后一步出啥问题吧。
: 电面题目:
: 一位国人大哥,先在这里谢过啦,时间刚好45分钟,吐槽下Google docs上写程序好蛋
: 疼,什么时候可以搞个可以支持Vim的编辑器吧。。。。
: Assume some binary (each pixel is either black or white ) images, have same
: width and height, and the length is power of 2. Present it by quadtree:
: divide the image into quarters, each quarter can be all back, all white or
: mixed, subdivide the mixed ones… recurse.
: +-------+---+---+

avatar
j*6
8
lz肯定没问题的 加油~
顺便lz能不能解释一下题目? 智商让人捉急 有点没看懂
还有那个图是什么意思?
avatar
w*7
9
b) count all the black pixels of this image
int getBlackPixels( TreeNode* root) {
if(!root)
return 0;
if( !root->upperLeft) {
if( root->pixel)
return root->size * root->size;
}
int sum = 0;
sum += getBlackPixels( root->upperLeft);
sum += getBlackPixels( root->downLeft);
sum += getBlackPixels( root->upperRight);
sum += getBlackPixels( root->downRight);
return sum;
}
The code above does not look right. A node will have its pixel size only
when it has no child node. So a node's subnode shall be checked before you
return its size.
avatar
i*0
10
re
avatar
l*h
11
You can judge on all four nodes and actually initially I did this way. But
the interviewer said you either have leaf nodes or nodes always with 4
children. Thus judging on 1 is sufficient.

【在 w**7 的大作中提到】
: b) count all the black pixels of this image
: int getBlackPixels( TreeNode* root) {
: if(!root)
: return 0;
: if( !root->upperLeft) {
: if( root->pixel)
: return root->size * root->size;
: }
: int sum = 0;
: sum += getBlackPixels( root->upperLeft);

avatar
l*h
12
就是一个正方形黑白图片(边长是2的次方)用一个4叉树来表示~

【在 j*********6 的大作中提到】
: lz肯定没问题的 加油~
: 顺便lz能不能解释一下题目? 智商让人捉急 有点没看懂
: 还有那个图是什么意思?

avatar
c*e
13
gx!
avatar
B*c
14
congrats!进来占喜气
avatar
x*1
15
big cong! 进来沾沾喜气~~
avatar
f*2
16
big cong!
avatar
c*p
17
mark
avatar
x*0
18
m
avatar
l*a
19
恭喜!顺带沾喜气!
avatar
b*f
20
Mark
avatar
T*n
21
询问楼主,找工作这半年,身份是怎么解决的呀
avatar
H*s
22
Gx gx!

【在 l***h 的大作中提到】
: 就是一个正方形黑白图片(边长是2的次方)用一个4叉树来表示~
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。