2015年1月10日

摘要: 题目:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.代码:oj测试通过Runtime:231 ms 1 # Definition for singly-l... 阅读全文
posted @ 2015-01-10 13:57 承续缘 阅读(1032) 评论(0) 推荐(0) 编辑
摘要: 题目: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 or... 阅读全文
posted @ 2015-01-10 11:06 承续缘 阅读(250) 评论(0) 推荐(0) 编辑

2015年1月9日

摘要: 题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your al... 阅读全文
posted @ 2015-01-09 23:49 承续缘 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a singly linked listL: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 e... 阅读全文
posted @ 2015-01-09 23:19 承续缘 阅读(275) 评论(1) 推荐(0) 编辑
摘要: 原题:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen lef... 阅读全文
posted @ 2015-01-09 11:22 承续缘 阅读(221) 评论(0) 推荐(0) 编辑

2015年1月8日

摘要: 题目:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL... 阅读全文
posted @ 2015-01-08 23:44 承续缘 阅读(1118) 评论(0) 推荐(0) 编辑
摘要: 题目:Sort a linked list inO(nlogn) time using constant space complexity.代码:oj 测试通过Runtime:372 ms 1 # Definition for singly-linked list. 2 # class ListNo... 阅读全文
posted @ 2015-01-08 17:28 承续缘 阅读(379) 评论(0) 推荐(0) 编辑

2015年1月3日

摘要: 题目:Sort a linked list using insertion sort.代码:oj测试通过Runtime:860 ms 1 # Definition for singly-linked list. 2 # class ListNode: 3 # def __init__(sel... 阅读全文
posted @ 2015-01-03 19:54 承续缘 阅读(368) 评论(0) 推荐(0) 编辑
摘要: 公司和学校事情比较多,隔了好几天没刷题,今天继续刷起来。题目:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve i... 阅读全文
posted @ 2015-01-03 15:58 承续缘 阅读(305) 评论(0) 推荐(0) 编辑

2014年12月27日

摘要: 题目:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".代码:oj在线测试通过Runtime:172 ms 1... 阅读全文
posted @ 2014-12-27 00:12 承续缘 阅读(282) 评论(0) 推荐(0) 编辑

导航