摘要: http://www.cnblogs.com/AnnieKim/archive/2013/06/15/MorrisTraversal.html 阅读全文
posted @ 2016-03-08 21:30 背锅侠 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 快慢指针是链表中常用的技巧,反转链表也是常用算法之一。 使用p和q两个指针配合工作,使得两个节点间的指向反向,同时用r记录剩下的链表。p = head; q = head->next; head->next = NULL; 现在进入循环体,这是第一次循环。 r = q->nex... 阅读全文
posted @ 2016-03-08 19:59 背锅侠 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 1、欧几里德算法(辗转相除法)最大公约数 greatest common divisor,简写为gcd;或highestcommon factor,简写为hcf 最小公倍数 最小公倍数(Least Common Multiple,缩写L.C.M.)最小公倍数=两数的乘积/最大公约数... 阅读全文
posted @ 2016-03-05 20:35 背锅侠 阅读(905) 评论(0) 推荐(0) 编辑
摘要: 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 ... 阅读全文
posted @ 2016-03-05 20:20 背锅侠 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 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 prese... 阅读全文
posted @ 2016-03-04 13:00 背锅侠 阅读(125) 评论(0) 推荐(0) 编辑
摘要: iven 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... 阅读全文
posted @ 2016-03-04 09:44 背锅侠 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 问题描述Given a singly linked list, determine if it is a palindrome. 【解题思路】 1. 遍历链表,快慢指针,找到链表后半部分。 2. 反转链表,可以参考Reverse Linked List。 3. 然后比较前半部... 阅读全文
posted @ 2016-03-02 21:36 背锅侠 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 问题描述Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/sp... 阅读全文
posted @ 2016-02-29 21:02 背锅侠 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list using insertion sort.解法:Well, life gets difficult pretty soon whenever the same operation on array is transferred to linke... 阅读全文
posted @ 2016-02-29 16:58 背锅侠 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write a function to determine if it is a power of three.Follow up: Could you do it without using any loop / recursion?解决方法:... 阅读全文
posted @ 2016-02-13 13:30 背锅侠 阅读(182) 评论(0) 推荐(0) 编辑