i**********b 发帖数: 77 | 1 1)为什么 new 出来的object 不能用free。 malloc出来的object不能用delete。
我说了constructor,destructor 的原因.他们还问有没有其他原因。假设不涉及资源
分配问题。
2)SQL alias是用来干嘛的。不会,乱答的
3)为什么assign operator 不能自己assign 给自己。没打上来
4)算法题: 一个array里找唯一一个duplicated integer
5)abstract class, pure virtual function. why use them
两个老印,一男一女。女的极度tough. 我还在一边说一边想呢。她居然challenge我说
"now what?!" 算法题我给了两个解法。一个sort,binary search,另一个bitwise
XOR。那个男的让我用个例子go through 一下。我马上就快说完了。那女的居然说“we
are running out of time".其实才不到45分钟。而且我就差一句了。 剩下的15分钟
我可以问问题。真没礼貌。 不知道bloomberg的人 |
l******4 发帖数: 729 | |
p******r 发帖数: 2999 | 3 原理不一样呗
【在 l******4 的大作中提到】 : 第一个是为什么?
|
y*c 发帖数: 904 | 4 貌似 bloomberg 的人的 interview skill 确实需要提高。 |
h**6 发帖数: 4160 | 5 昨天跟mm说到bloomberg,mm很好奇的问,这个berg是鸡肉的还是牛肉的。 |
M********5 发帖数: 715 | 6 第三个问题的答案是避免产生dangling pointer |
j**l 发帖数: 2911 | 7 林锐的书有个例子
String& String::operator=(const String& other)
{
if (this != &other)
{
delete[] m_data;
int len = strlen(other.m_data);
m_data = new char[len + 1];
strcpy(m_data, other.m_data);
m_size = len;
}
return *this;
}
如果不检查自赋值,delete后又去复制自己,就访问了dangling的野指针,这是危险的。
【在 M********5 的大作中提到】 : 第三个问题的答案是避免产生dangling pointer
|
c******n 发帖数: 710 | 8 算法题,请教一下用xor怎么实现的?
we
【在 i**********b 的大作中提到】 : 1)为什么 new 出来的object 不能用free。 malloc出来的object不能用delete。 : 我说了constructor,destructor 的原因.他们还问有没有其他原因。假设不涉及资源 : 分配问题。 : 2)SQL alias是用来干嘛的。不会,乱答的 : 3)为什么assign operator 不能自己assign 给自己。没打上来 : 4)算法题: 一个array里找唯一一个duplicated integer : 5)abstract class, pure virtual function. why use them : 两个老印,一男一女。女的极度tough. 我还在一边说一边想呢。她居然challenge我说 : "now what?!" 算法题我给了两个解法。一个sort,binary search,另一个bitwise : XOR。那个男的让我用个例子go through 一下。我马上就快说完了。那女的居然说“we
|
i**********b 发帖数: 77 | 9 哦。array length n,
the range of the integers in the array is n-1.
所以只有一个duplicated.
比如:
array: 1, 2, 3, 2, 4
len = 5;
range 1 - 4;
第一步:
sum = 1 ^ 2 ^ 3 ^ 4
第二步:
用sum 去 XOR array中每个一个元素
只有 2 被XOR了两次。 其他1,3,4都被XOR了一次。
bitwise XOR 有个特点。 x ^ x = 0 (一次XOR)
x ^ x ^ x = x (两次XOR)
所以上面两个步骤之后最后 sum = 2
这个题貌似很经典吧。呵呵 |
i**********b 发帖数: 77 | 10 是啊是啊。
一时没有想起来。 :(
【在 M********5 的大作中提到】 : 第三个问题的答案是避免产生dangling pointer
|
|
|
l******c 发帖数: 2555 | 11 there is no fixed range for the number in the array.
【在 i**********b 的大作中提到】 : 哦。array length n, : the range of the integers in the array is n-1. : 所以只有一个duplicated. : 比如: : array: 1, 2, 3, 2, 4 : len = 5; : range 1 - 4; : 第一步: : sum = 1 ^ 2 ^ 3 ^ 4 : 第二步:
|
l******c 发帖数: 2555 | 12 there is no fixed range for the number in the array.
【在 i**********b 的大作中提到】 : 哦。array length n, : the range of the integers in the array is n-1. : 所以只有一个duplicated. : 比如: : array: 1, 2, 3, 2, 4 : len = 5; : range 1 - 4; : 第一步: : sum = 1 ^ 2 ^ 3 ^ 4 : 第二步:
|
M********5 发帖数: 715 | 13
不用担心,面试的时候等发挥80%就不错了,这里面有几个题我也不会
可怜的是我现在什么都没有,投公司一个都不回
【在 i**********b 的大作中提到】 : 是啊是啊。 : 一时没有想起来。 :(
|
p********7 发帖数: 549 | 14 他为什么考你SQL呢? 难道lz简历写了自己会? |
j***u 发帖数: 16 | 15 这个bitwise xor 只适合 连续 array 吧. 对非连续 的无效.
最好还是先排序, 然后找, 反正duplicated integer是前后相邻的 |