摘要: 题目:Sort a linked list in O(n log n) time using constant space complexity.解题思路:根据题目要求,可知只能用归并排序,其他排序算法要么时间复杂度不满足,要么空间复杂度不满足实现代码:#include using namespac... 阅读全文
posted @ 2014-02-16 23:39 mickole 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 题目:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another... 阅读全文
posted @ 2014-02-16 22:14 mickole 阅读(305) 评论(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".Clarification:What c... 阅读全文
posted @ 2014-02-16 22:08 mickole 阅读(427) 评论(0) 推荐(0) 编辑
摘要: 题目:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.解题思路:1,在所有点中选定一个点作为中心点,然后再求剩下的点到该中心点的斜率,如果斜率相同的点... 阅读全文
posted @ 2014-02-16 22:03 mickole 阅读(316) 评论(0) 推荐(0) 编辑