![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LinkList
文章平均质量分 74
benbenab
这个作者很懒,什么都没留下…
展开
-
Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space.原创 2012-11-13 11:50:00 · 256 阅读 · 0 评论 -
两个list相加
150题 2.5ListNode* AddList(ListNode* root1, ListNode* root2,int& carry){ if (root1==NULL && root2==NULL) return NULL; ListNode* result = AddList(root1->next,root2->next,carry); ListNode* temp =原创 2012-12-04 06:32:02 · 4796 阅读 · 0 评论 -
[leetcode] BST与链表的相互转换
1. 链表-->BST (借鉴smile的)/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *//** * Definition原创 2012-12-31 12:17:10 · 1430 阅读 · 0 评论 -
[leetcode] merge k sort list
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: typedef stru原创 2013-01-01 23:55:27 · 497 阅读 · 0 评论 -
deep copy 带有random的linklist
题目:有一个链表L,其每个节点有2个指针,一个指针next指向链表的下个节点,另一个random随机指向链表中的任一个节点,可能是自己或者为空,写一个程序,要求复制这个链表的结构并分析其复杂性解决方法一:O(n)的复杂度,扫面两边即可。缺点:修改了原始的链表转载 2012-12-20 23:48:58 · 489 阅读 · 0 评论 -
[leetcode] Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1原创 2013-01-23 06:49:34 · 346 阅读 · 0 评论 -
[leetcode] Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL./** * Definition for singly-li原创 2013-01-28 03:26:48 · 311 阅读 · 0 评论 -
【leetcode】 Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If原创 2013-01-31 11:35:03 · 283 阅读 · 0 评论