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