Redian新闻
>
没人再讨论AIG?
avatar
没人再讨论AIG?# Stock
s*e
1
今天看到leetcode的新题,单链表插入排序,本来准备做一下再吃午饭的。结果楞是写
了一个小时,中间bug无数。
感觉对人生失去信心了。
avatar
x*0
2
?
avatar
n*e
3
同感啊,觉得面试官从intro to algorithms 里面找一个例题或者一个algorithm出来
让写code, implement一下。 40分钟不一定能搞定啊
avatar
c*l
4
都见外婆了还讨论什么
avatar
x*8
5
我也写了一会儿,主要注意一些细节
avatar
h*8
6
all doom
avatar
J*3
7
是啊 一看挺简单 具体写起来不容易bug free哦
avatar
p*a
8
all the AIG guys will be wiped out
avatar
f*4
9
忘记在一开始的时候让head->next=NULL的飘过..
avatar
h*n
10
no need to 讨论
avatar
b*6
11
patpat
avatar
K*n
12
我都割肉了,下面没人了
avatar
m*g
13
多刷刷就有感觉了, 模式熟悉之后,直接套上去。 笨人的想法 :)
羡慕大牛们干什么都是一气哈成。
avatar
c*c
14
跌倒china007卖了为止。

【在 K*****n 的大作中提到】
: 我都割肉了,下面没人了
avatar
h*o
15
同样。。一小时。。。

【在 s***e 的大作中提到】
: 今天看到leetcode的新题,单链表插入排序,本来准备做一下再吃午饭的。结果楞是写
: 了一个小时,中间bug无数。
: 感觉对人生失去信心了。

avatar
g*l
16
我没割,AIG没有问题,有钱再补点,昂首迎接下一次冲锋
avatar
d*x
17
not that hard...
handle all corner cases explicitly... then you are good...

【在 h*********o 的大作中提到】
: 同样。。一小时。。。
avatar
b*t
18
近期不敢碰
avatar
k*4
19
貌似加个dummyHead还是挺好写的
ListNode *insertionSortList(ListNode *head) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
ListNode dummyHead(INT_MIN);
ListNode *p = head;
while(p != NULL)
{
ListNode *pre = &dummyHead;
while(pre->next != NULL && pre->next->val < p->val)
pre = pre->next;
ListNode *temp = p->next;
p->next = pre->next;
pre->next = p;
p = temp;
}
return dummyHead.next;
}
avatar
l*6
20
will hold it after next ER.
What is AIG next ER Date?
avatar
b*6
21
那我也贴个java的好了
public ListNode insertionSortList(ListNode head) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
if (head == null) return null;
ListNode dummy = new ListNode(-1);
dummy.next = head;

ListNode i = head;
while (i.next != null) {
int n = i.next.val;
ListNode j = dummy;
while (j!=i&&j.next.val < n){
j = j.next;
}
if (j == i) {

i = i.next;
continue;
}
ListNode pivot = i.next;
i.next = i.next.next;
pivot.next = j.next;
j.next = pivot;
}

return dummy.next;
}

【在 k******4 的大作中提到】
: 貌似加个dummyHead还是挺好写的
: ListNode *insertionSortList(ListNode *head) {
: // IMPORTANT: Please reset any member data you declared, as
: // the same Solution instance will be reused for each test case.
: ListNode dummyHead(INT_MIN);
: ListNode *p = head;
: while(p != NULL)
: {
: ListNode *pre = &dummyHead;
: while(pre->next != NULL && pre->next->val < p->val)

avatar
k*u
22
兄弟你搞错了,是China2007.
我得纠正一下,免得误伤。
发信人: ctc (信通), 信区: Stock
标 题: Re: 没人再讨论AIG?
发信站: BBS 未名空间站 (Thu Jan 28 12:58:53 2010, 美东)
跌倒china007卖了为止。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。