题目链接题意: 给出单链表, 判断是否存在环.方法就是大步小步...附上代码: 1 /** 2 *
Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 *
ListNode *next...
分类:
其他好文 时间:
2014-05-20 01:46:54
阅读次数:
308
题目:移除linked-list从尾到头的第N个元素自我思路:因为题目给出的N是从链表尾开始计算的,单链表不存在从子指向父亲的反向指针,因此我先计算链表的整个长度len,然后用len
- N来表示正向被删除元素所在的位置。代码:public ListNode removeNthFromEnd(Lis...
分类:
其他好文 时间:
2014-05-19 20:54:33
阅读次数:
378
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-19 11:38:43
阅读次数:
246
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 removi...
分类:
其他好文 时间:
2014-05-19 09:16:49
阅读次数:
247
【题目】
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
You may not alter the values in the nodes, only n...
分类:
其他好文 时间:
2014-05-18 10:22:34
阅读次数:
367
【题目】
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. You may not modify the values in the list, only nodes it...
分类:
其他好文 时间:
2014-05-18 08:37:57
阅读次数:
370
1、
??
Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below...
分类:
其他好文 时间:
2014-05-18 03:25:06
阅读次数:
301
Given a linked list and a value x, partition it
such that all nodes less than x come before nodes greater than or equal to x.You
should preserve the o...
分类:
其他好文 时间:
2014-05-18 02:34:57
阅读次数:
352
Given a linked list, reverse the nodes of a
linked list k at a time and return its modified list.If the number of nodes is
not a multiple of k then le...
分类:
其他好文 时间:
2014-05-18 01:53:53
阅读次数:
331
Remove Duplicates from Sorted List IGiven a
sorted linked list, delete all duplicates such that each element appear only
once.For example,Given 1->1->...
分类:
其他好文 时间:
2014-05-18 01:41:31
阅读次数:
361