额,快慢指针,单指针是没必要当作题来做的。 /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func middleNode(head *ListNo ...
分类:
其他好文 时间:
2020-03-23 23:35:00
阅读次数:
115
1 //前序 2 void preOrderUnRecur(ListNode* head) 3 { 4 cout << "pre-order: "; 5 if (head != NULL) 6 { 7 stack<ListNode*> Stack; 8 Stack.push(head); 9 10 ...
分类:
其他好文 时间:
2020-03-23 16:49:34
阅读次数:
47
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; ...
分类:
编程语言 时间:
2020-03-22 01:19:40
阅读次数:
66
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; ...
分类:
其他好文 时间:
2020-03-21 23:09:33
阅读次数:
48
#include<iostream> #include <stack> #include <algorithm> #include <string> using namespace std; typedef struct ListNode { int data; struct ListNode* n ...
分类:
其他好文 时间:
2020-03-21 21:21:36
阅读次数:
60
```python class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # 返回从尾部到头部的列表值序列,例如[1,2,3] def printListFromTailToHead(... ...
分类:
编程语言 时间:
2020-03-21 16:16:02
阅读次数:
80
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; ...
分类:
其他好文 时间:
2020-03-20 10:48:21
阅读次数:
55
题目描述 输入一个链表,反转链表后,输出新链表的表头。 题目详解 递归,先顺序递归到倒数第二个节点。然后以此回归,并设置head.next = null。保证首节点反转变成最后一个节点后的下一个节点为null。 /* public class ListNode { int val; ListNode ...
分类:
其他好文 时间:
2020-03-18 21:41:47
阅读次数:
54
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; ...
分类:
其他好文 时间:
2020-03-15 18:55:57
阅读次数:
53
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; ...
分类:
其他好文 时间:
2020-03-15 18:52:06
阅读次数:
51