上一页 1 ··· 3 4 5 6 7
摘要: 题目: Sort a linked list inO(nlogn) time using constant space complexity.解题思路: 复杂度为O(n* logn) 的排序算法有:快速排序、堆排序、归并排序。对于链表这种数据结构,使用归并排序比较靠谱。递归代码如下:代码: /... 阅读全文
posted @ 2014-05-13 19:41 ThreeMonkey 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 题目: Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.解题思路: 第一反应:枚举两个点组成的直线,然后看其他的点在不在这条直线上,在此过程中统计最大... 阅读全文
posted @ 2014-05-13 19:37 ThreeMonkey 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目: Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another e... 阅读全文
posted @ 2014-05-13 19:28 ThreeMonkey 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 题目: Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the".解题思路: 1、先对字符串进行一次总... 阅读全文
posted @ 2014-05-13 19:16 ThreeMonkey 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 题目:Reverse Words in a String Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".C... 阅读全文
posted @ 2014-03-31 11:55 ThreeMonkey 阅读(286) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7