avatar
140K Hilton Honors point# Money - 海外理财
g*s
1
就是有2个linkedlist,size都为n, 他们可能merge,就是share at least on common
node,问怎么判断是否merge,找
那个common node.
naive的方法就是2个loop,比较address了。o(n squre)
我想了个方法就是,2个list按address排序,这样是o(nlogn),然后比较address in
two sorted list, 这样是o(n)。
还有更好的办法么?
avatar
n*y
2
发信人: newjersey (NJ furniture dealer), 信区: EasyMoney
标 题: 140K Hilton Honors point
发信站: BBS 未名空间站 (Thu Mar 29 13:00:56 2012, 美东)
there are 2 offers for Hawaiian airline credit cards. Each offer from
BOA and Bank of Hawaii gives you 35K miles. From the Hawaiian Airlines
Terms and Conditions page, the airlines miles will be transferred at the
ratio of 1:2 for Hilton Honor points. That means you can potentially have
140K HH points by applying for these credit cards.
http://www.mitbbs.com/club_bbsdoc/EasyMoney.html
avatar
c*o
3
假如merge的话,tail 应该是一样的。所以从两个head开始往前走到tail,看看两个
tail是不是相
等就可以了

common

【在 g*******s 的大作中提到】
: 就是有2个linkedlist,size都为n, 他们可能merge,就是share at least on common
: node,问怎么判断是否merge,找
: 那个common node.
: naive的方法就是2个loop,比较address了。o(n squre)
: 我想了个方法就是,2个list按address排序,这样是o(nlogn),然后比较address in
: two sorted list, 这样是o(n)。
: 还有更好的办法么?

avatar
n*y
4
发信人: newjersey (NJ furniture dealer), 信区: EasyMoney
标 题: Re: 140K Hilton Honors point
发信站: BBS 未名空间站 (Wed Apr 18 15:33:37 2012, 美东)
130,000 Hilton HHonors points!
Bank of America Virgin Atlantic American Express® Card
Reach rewards faster with up to 65,000 Flying Club bonus miles in the first
year with the Virgin Atlantic American Express® Card from Bank of
America.
* 20,000 Flying Club bonus miles after your first retail purchase§
* 25,000 additional Flying Club bonus miles after you spend at least $2,
500 in qualifying purchases§
* Earn up to 15,000 additional bonus miles upon anniversary§
* Earn up to 5,000 Flying Club bonus miles when you add additional
authorized users to your Card§
* Earn 3 miles per $1 spent directly on Virgin Atlantic purchases and 1.
5 miles per $1 spent on all other purchases§
Transfer to Hilton HHonors points 2 to 1 to end up with 130,000 Hilton
HHonors points!
avatar
g*s
5
对。。我傻了= =,我一直纠结于merge之后还会diverge的想法。。。

【在 c****o 的大作中提到】
: 假如merge的话,tail 应该是一样的。所以从两个head开始往前走到tail,看看两个
: tail是不是相
: 等就可以了
:
: common

avatar
n*y
6
发信人: reyishi (renyishi), 信区: Money
标 题: Re: 求Hilton AMEX 62500申请页面copy
发信站: BBS 未名空间站 (Wed Jun 29 04:56:29 2011, 美东)
21000点可以换上海虹桥希尔顿,如果是金卡再免费升房,送2人早餐,早餐每人215RMB
,酒店硬软件都超级赞,房间非常棒
avatar
t*0
7
me too.

【在 g*******s 的大作中提到】
: 对。。我傻了= =,我一直纠结于merge之后还会diverge的想法。。。
avatar
s*r
8
太复杂,而且两个hard。
avatar
h*d
9
对。。。那样是O(2N)了吧

【在 c****o 的大作中提到】
: 假如merge的话,tail 应该是一样的。所以从两个head开始往前走到tail,看看两个
: tail是不是相
: 等就可以了
:
: common

avatar
e*n
10
那个Hawaiian airline credit cards可以同时申BOA and Bank of Hawaii,但2家都不
免第一年年费啊
avatar
c*2
11
since both sizes are n, if they converge, it must be a symetrical Y.
so one loop to traverse both simutaneously and check whether two addresses
are equal to get the common one.
avatar
J*t
12
typedef struct node
{
int data;
struct node * next;
}Node;
/* O(n) solution */
Node * findCommonNodes(Node * head1, Node * head2)
{
while(head1)
{
if (head1 == head2)
{
return head1;
}
else
{
head1 = head1->next;
head2 = head2->next;
}
}
return NULL;
}

【在 c***2 的大作中提到】
: since both sizes are n, if they converge, it must be a symetrical Y.
: so one loop to traverse both simutaneously and check whether two addresses
: are equal to get the common one.

avatar
y*2
13
为啥tail就一定相等

【在 c****o 的大作中提到】
: 假如merge的话,tail 应该是一样的。所以从两个head开始往前走到tail,看看两个
: tail是不是相
: 等就可以了
:
: common

avatar
g*k
14
share the same common node, then it must have the same next pointer.

【在 y*****2 的大作中提到】
: 为啥tail就一定相等
avatar
g*k
15
This is wrong, suppose the same node appears 2nd in the first list
and 3rd in the second list.
So your code only solves the problem when the same node is at the same rank
in
each list.

typedef struct node
{
int data;
struct node * next;
}Node;
/* O(n) solution */
Node * findCommonNodes(Node * head1, Node * head2)
{
while(head1)
{
if (head1 == head2)
{
return head1;
}
else
{
head1 = head1->next;
head2 = head2->next;
}
}
return NULL;
}

【在 J******t 的大作中提到】
: typedef struct node
: {
: int data;
: struct node * next;
: }Node;
: /* O(n) solution */
: Node * findCommonNodes(Node * head1, Node * head2)
: {
: while(head1)
: {

avatar
y*a
16
题目说了两个linked list size 相等

rank

【在 g*****k 的大作中提到】
: This is wrong, suppose the same node appears 2nd in the first list
: and 3rd in the second list.
: So your code only solves the problem when the same node is at the same rank
: in
: each list.
:
: typedef struct node
: {
: int data;
: struct node * next;

avatar
g*k
17
I see

【在 y*****a 的大作中提到】
: 题目说了两个linked list size 相等
:
: rank

avatar
c*2
18
good one.
Also I like your "head picture". She is also my favorite.
Met a girl who looks like Zhao YaZhi when I was in college.
Fallen love with her, but pitfully both of us are married... sigh........

【在 J******t 的大作中提到】
: typedef struct node
: {
: int data;
: struct node * next;
: }Node;
: /* O(n) solution */
: Node * findCommonNodes(Node * head1, Node * head2)
: {
: while(head1)
: {

avatar
b*y
19
Like your story :-)

【在 c***2 的大作中提到】
: good one.
: Also I like your "head picture". She is also my favorite.
: Met a girl who looks like Zhao YaZhi when I was in college.
: Fallen love with her, but pitfully both of us are married... sigh........

avatar
d*w
20
大家可以看这个
http://geeksforgeeks.org/?p=2405
详细叙述了在通用情况下的算法

common

【在 g*******s 的大作中提到】
: 就是有2个linkedlist,size都为n, 他们可能merge,就是share at least on common
: node,问怎么判断是否merge,找
: 那个common node.
: naive的方法就是2个loop,比较address了。o(n squre)
: 我想了个方法就是,2个list按address排序,这样是o(nlogn),然后比较address in
: two sorted list, 这样是o(n)。
: 还有更好的办法么?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。