码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
【LeetCode】Partition List
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi...
分类:其他好文   时间:2014-05-24 04:59:06    阅读次数:275
Leetcode ---- Swap Nodes in Pairs
题目链接题意:给出单链表头指针,要求交换链表中每一对相邻的结点.注意:不可以改变链表中结点的值,只可以使用常量空间.附上代码: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val;...
分类:其他好文   时间:2014-05-23 10:43:49    阅读次数:249
leetcode -day19 Convert Sorted List to Binary Search Tree
1、 ?? Convert Sorted List to Binary Search Tree  Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 分析:将一个升序排列的链表转换为平衡二叉搜索树,采用递归的方式,先找到链表...
分类:其他好文   时间:2014-05-22 12:33:30    阅读次数:270
CareerCup之2.1无序链表删除重复元素
【题目】 原文: 2.1 Write code to remove duplicates from an unsorted linked list. FOLLOW UP How would you solve this problem if a temporary buffer is not allowed? 译文: 从一个未排序的链表中移除重复的项 ...
分类:其他好文   时间:2014-05-22 12:04:13    阅读次数:196
leetcode:Insert Sort List
问题描述 对一个单链表进行插入排序,head指向第一个结点。 代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */...
分类:其他好文   时间:2014-05-22 10:15:43    阅读次数:233
CareerCup之2.2 寻找单链表倒数第n个元素
【题目】 原文: 2.2 Implement an algorithm to find the nth to last element of a singly linked list. 译文: 实现一个算法从一个单链表中返回倒数第n个元素。 【分析】 【思路一】 (1)创建两个指针p1和p2,指向单链表的开始节点。 (2)使p2移动n-1个位置,使之指向从头...
分类:其他好文   时间:2014-05-22 09:03:53    阅读次数:315
leetcode:Reorder List
问题 Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example, Given {1,2,3,4}, reorde...
分类:其他好文   时间:2014-05-22 07:04:46    阅读次数:298
Leetcode:Remove Nth Node From End of List
戳我去解题Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. Aft...
分类:其他好文   时间:2014-05-20 08:04:28    阅读次数:291
【leetcode】Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ...
分类:其他好文   时间:2014-05-19 15:50:28    阅读次数:447
LeetCode: Remove Nth Node From End of List [019]
【题目】 Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given n will ...
分类:其他好文   时间:2014-05-18 18:48:03    阅读次数:269
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!