Skip to content

Commit 025d6a7

Browse files
committed
剑指Offer–037-两个链表的第一个公共结点--http://blog.csdn.net/gatieme/article/details/51330871
1 parent 4b1f411 commit 025d6a7

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

037-两个链表的第一个公共结点/README.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
#链接
2-
-------
2+
-------
33
>牛客OJ:[两个链表的第一个公共结点](http://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&rp=2&ru=%2Fta%2Fcoding-interviews&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking)
4-
>
4+
>
55
>九度OJ:http://ac.jobdu.com/problem.php?pid=1505
6-
>
6+
>
77
>GitHub代码: [037-两个链表的第一个公共结点](https://github.com/gatieme/CodingInterviews/tree/master/037-两个链表的第一个公共结点)
88
>
99
>CSDN题解:[剑指Offer--037-两个链表的第一个公共结点](http://blog.csdn.net/gatieme/article/details/51330871)
1010
1111

12-
| 牛客OJ | 九度OJ | CSDN题解 | GitHub代码 |
13-
| ------------- |:-------------:| -----:|
12+
| 牛客OJ | 九度OJ | CSDN题解 | GitHub代码 |
13+
| ------------- |:-------------:| -----:|
1414
|[037-两个链表的第一个公共结点](http://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&rp=2&ru=%2Fta%2Fcoding-interviews&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking) | [1505-两个链表的第一个公共结点](http://ac.jobdu.com/problem.php?pid=1505) | [剑指Offer--037-两个链表的第一个公共结点](http://blog.csdn.net/gatieme/article/details/51330871) | [037-两个链表的第一个公共结点](https://github.com/gatieme/CodingInterviews/tree/master/037-两个链表的第一个公共结点) |
1515

1616

1717

18+
19+
<br>**您也可以选择[回到目录-剑指Offer--题集目录索引](http://blog.csdn.net/gatieme/article/details/51916802)**
20+
21+
22+
23+
1824
#题意
1925
-------
2026

@@ -80,7 +86,7 @@ public:
8086
if(left == right)
8187
{
8288
break;
83-
}
89+
}
8490
}
8591
if(left == right)
8692
{
@@ -194,7 +200,7 @@ public:
194200
195201
return ((left == right) ? left : NULL);
196202
}
197-
203+
198204
int GetListLength(ListNode *head)
199205
{
200206
ListNode *node = head;
@@ -203,7 +209,7 @@ public:
203209
{
204210
length++;
205211
node = node->next;
206-
}
212+
}
207213
208214
return length;
209215
}
@@ -284,7 +290,7 @@ public:
284290
{
285291
ListNode *left = leftHead;
286292
ListNode *right = rightHead;
287-
293+
288294
stack<ListNode *> leftStack;
289295
stack<ListNode *> rightStack;
290296

@@ -309,9 +315,9 @@ public:
309315
{
310316
left = leftStack.top( );
311317
right = rightStack.top( );
312-
318+
313319
debug <<left->val <<", " <<right->val <<endl;
314-
320+
315321
/// 不相同的元素就是合并的前一个结点
316322
if(left != right)
317323
{
@@ -359,14 +365,14 @@ public:
359365
ListNode* FindFirstCommonNode(ListNode *leftHead, ListNode *rightHead)
360366
{
361367
unordered_map<ListNode*, bool> umap;
362-
368+
363369
ListNode* left = leftHead;
364370
while (left != NULL)
365371
{
366372
umap.insert(make_pair(left, 1 ));
367373
left = left->next;
368374
}
369-
375+
370376
ListNode* right = rightHead;
371377
while (right)
372378
{
@@ -379,4 +385,4 @@ public:
379385
return NULL;
380386
}
381387
};
382-
```
388+
```

038-数字在排序数组中出现的次数/bruteforce.cpp renamed to 038-数字在排序数组中出现的次数/01-bruteforce.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <iostream>
22
#include <vector>
33

4+
45
using namespace std;
56

67
// µ÷ÊÔ¿ª¹Ø
@@ -49,6 +50,6 @@ int __tmain( )
4950
int arr[] = { 1, 2, 3, 3, 3, 3, 4, 5 };
5051
vector<int> vec(arr, arr + 8);
5152
cout <<solu.GetNumberOfK(vec, 3) <<endl;
52-
53+
5354
return 0;
5455
}

0 commit comments

Comments
 (0)