r*******g 发帖数: 1335 | 1 I saw this on careerup, not sure how to solve them. Thank you.
1, realize malloc() in C
What is key data structure here? What is the key point?
2 If [a1,a2,a3...,an,b1,b2...bn] is given input change this to [a1,b1,a2,b2.
....an,bn] , solution should be in-place
Anyone knows what is the most efficient solution? It is best if there is a
link provided.
3, Given an array of +ve and -ve integers, re-arrange it so that u have +ves
on one end and -ves on other,BUT RETAIN ORDER OF APPEARANCE..
for eg,
1,7,-5,9,-12,15
ans=
-5,-12,1,7,9,15
do it in O(n) without using any extra space.
I doubt it can be realized without extra space. Is there a solution using
constant space?
Surely linked list is a solution, what else can we get?
Thanks. | c*********t 发帖数: 2921 | 2 第三题前一段时间这里讨论过:好像只有O(nlogn)的方法。O(n)的不知道怎么弄?
b2.
ves
【在 r*******g 的大作中提到】 : I saw this on careerup, not sure how to solve them. Thank you. : 1, realize malloc() in C : What is key data structure here? What is the key point? : 2 If [a1,a2,a3...,an,b1,b2...bn] is given input change this to [a1,b1,a2,b2. : ....an,bn] , solution should be in-place : Anyone knows what is the most efficient solution? It is best if there is a : link provided. : 3, Given an array of +ve and -ve integers, re-arrange it so that u have +ves : on one end and -ves on other,BUT RETAIN ORDER OF APPEARANCE.. : for eg,
| c*********t 发帖数: 2921 | 3 http://www.mitbbs.com/article_t/JobHunting/31935043.html
的六楼,好像是回答了你的第二个问题。
可是我没有完全明白他的答案的意思。仅供参考。
b2.
ves
【在 r*******g 的大作中提到】 : I saw this on careerup, not sure how to solve them. Thank you. : 1, realize malloc() in C : What is key data structure here? What is the key point? : 2 If [a1,a2,a3...,an,b1,b2...bn] is given input change this to [a1,b1,a2,b2. : ....an,bn] , solution should be in-place : Anyone knows what is the most efficient solution? It is best if there is a : link provided. : 3, Given an array of +ve and -ve integers, re-arrange it so that u have +ves : on one end and -ves on other,BUT RETAIN ORDER OF APPEARANCE.. : for eg,
| r*******g 发帖数: 1335 | 4 co没看明白,不过第三题好像也不是o(n)
【在 c*********t 的大作中提到】 : http://www.mitbbs.com/article_t/JobHunting/31935043.html : 的六楼,好像是回答了你的第二个问题。 : 可是我没有完全明白他的答案的意思。仅供参考。 : : b2. : ves
|
|