b*******d 发帖数: 750 | 1 1.
写一个stack。
api是:
Stack pop();
Stack push(int value);
int top();
s2 = s1.pop();
那么s2是个独立的stack,但其值等于s1的常规pop之后的结果。s1 pop之后,仍保持原
来的内容,只产生一个新stack。
优化pop 和 push。
这个题我答的不好。有会的告诉哥一下。
2. 两个sorted array,A和B,找其中值。证明复杂度。 |
l*****a 发帖数: 14598 | 2 你多大?嫩没礼貌呢?
【在 b*******d 的大作中提到】 : 1. : 写一个stack。 : api是: : Stack pop(); : Stack push(int value); : int top(); : s2 = s1.pop(); : 那么s2是个独立的stack,但其值等于s1的常规pop之后的结果。s1 pop之后,仍保持原 : 来的内容,只产生一个新stack。 : 优化pop 和 push。
|
l*****a 发帖数: 14598 | 3 看起来像是用singly linked list 实现stack
成不?
【在 b*******d 的大作中提到】 : 1. : 写一个stack。 : api是: : Stack pop(); : Stack push(int value); : int top(); : s2 = s1.pop(); : 那么s2是个独立的stack,但其值等于s1的常规pop之后的结果。s1 pop之后,仍保持原 : 来的内容,只产生一个新stack。 : 优化pop 和 push。
|
b*******d 发帖数: 750 | 4
ok,
"这个题我答的不好。有会的告诉哥一下。" ---->有会的告诉我一下。
【在 l*****a 的大作中提到】 : 你多大?嫩没礼貌呢?
|
l****c 发帖数: 782 | 5 都拿到大offer了,有资本傲一下,haha~
【在 b*******d 的大作中提到】 : : ok, : "这个题我答的不好。有会的告诉哥一下。" ---->有会的告诉我一下。
|
c*****n 发帖数: 96 | 6 I guess we can use copy-on-write (copy-on-push) technology. Each stack keep
a pointer of the top element and shares the same array(the internal element
container) among stacks(generated by pop()), and only create a private
array when the first push is called.
【在 b*******d 的大作中提到】 : 1. : 写一个stack。 : api是: : Stack pop(); : Stack push(int value); : int top(); : s2 = s1.pop(); : 那么s2是个独立的stack,但其值等于s1的常规pop之后的结果。s1 pop之后,仍保持原 : 来的内容,只产生一个新stack。 : 优化pop 和 push。
|
l****c 发帖数: 782 | 7 do you think the size of array is a problem?
keep
element
【在 c*****n 的大作中提到】 : I guess we can use copy-on-write (copy-on-push) technology. Each stack keep : a pointer of the top element and shares the same array(the internal element : container) among stacks(generated by pop()), and only create a private : array when the first push is called.
|
l****c 发帖数: 782 | 8 two sorted array那题,lz用什么方法解的呢?这题看的很眼熟啊。 |
l*****a 发帖数: 559 | 9 Copy-on-write does not optimize push()/pop() operation.
Its main purpose is to save space.
keep
element
【在 c*****n 的大作中提到】 : I guess we can use copy-on-write (copy-on-push) technology. Each stack keep : a pointer of the top element and shares the same array(the internal element : container) among stacks(generated by pop()), and only create a private : array when the first push is called.
|
c*****n 发帖数: 96 | 10 Then what's the definition of optimization ? Thanks.
【在 l*****a 的大作中提到】 : Copy-on-write does not optimize push()/pop() operation. : Its main purpose is to save space. : : keep : element
|
l*****a 发帖数: 559 | |