码迷,mamicode.com
首页 >  
搜索关键字:listnode    ( 1413个结果
leetcode--009 Linked List Cycle I
1 public boolean hasCycle(ListNode head) { 2 ListNode s=head; 3 ListNode f=head; 4 while(f!=null&&f.next!=null){ 5 ...
分类:其他好文   时间:2014-07-31 16:14:27    阅读次数:223
leetcode--010 Linked List Cycle II
1 public ListNode detectCycle(ListNode head) { 2 ListNode s=head; 3 ListNode f=head; 4 while(f!=null&&f.next!=null){ 5 ...
分类:其他好文   时间:2014-07-31 16:01:36    阅读次数:167
LeetCode "Reverse Linked List II"
Just corner case..class Solution {public: ListNode *reverseBetween(ListNode *head, int m, int n) { if(m == n) return head; ListNode *...
分类:其他好文   时间:2014-07-31 09:34:05    阅读次数:245
将两个有序链表和为另外一个链表,并保证有序
直接递归 代码: #include #include using namespace std; typedef struct listNode{ int key; struct listNode *pNext; } * pNode,Node; void createNode(pNode &pHead){ bool isFirst=true; int temp; sc...
分类:其他好文   时间:2014-07-30 20:57:14    阅读次数:174
leetcode-006 detect cycle
1 package leetcode; 2 3 public class DetectCycle { 4 public ListNode detectCycle(ListNode head) { 5 ListNode s=head; 6 ListNode ...
分类:其他好文   时间:2014-07-30 20:20:04    阅读次数:243
leetcode-005 reorder list
1 package leetcode; 2 3 public class ReOrderList { 4 public void reorderList(ListNode head) { 5 if(head==null||head.next==null||head.ne...
分类:其他好文   时间:2014-07-30 20:05:54    阅读次数:243
从尾到头打印链表
使用数据结构stack或者递归 1 使用stack #include #include using namespace std; typedef struct listNode{ int key; struct listNode *pNext; } * pNode,Node; void createNode(pNode &pHead){ bool isFirst=true;...
分类:其他好文   时间:2014-07-30 17:30:34    阅读次数:189
Sort List
归并排序的链表法#includeusing namespace std;struct ListNode{ int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution{public:...
分类:其他好文   时间:2014-07-30 07:40:23    阅读次数:174
[LeetCode 题解]: Insertion Sort List
Sort a linked list using insertion sort.题目要求:链表的插入排序,由于没有时间复杂度的要求,可以直接循环操作。/** * Definition for singly-linked list. * struct ListNode { * int val;...
分类:其他好文   时间:2014-07-29 10:54:26    阅读次数:190
LeetCode : add two numbers
解法:比较简单,用plus表示进位 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(in...
分类:其他好文   时间:2014-07-29 10:53:06    阅读次数:273
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!