12 2013 档案

[LeetCode] Evaluate Reverse Polish Notation, Solution
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e... 阅读全文

posted @ 2013-12-07 14:20 小刀初试 阅读(174) 评论(0) 推荐(0)

[LeetCode] Clone Graph, Solution
摘要:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled... 阅读全文

posted @ 2013-12-05 15:01 小刀初试 阅读(128) 评论(0) 推荐(0)

[LeetCode] Sort List, Solution
摘要:Sort a linked list in O(n log n) time using constant space complexity.[Thoughts]O(nlgn)的排序算法没几个,无非就是quick sort, heap sort和merge sort. 对于链表排序来说,难点之一就是如... 阅读全文

posted @ 2013-12-04 14:53 小刀初试 阅读(246) 评论(0) 推荐(0)

[LeetCode] Max Points on a Line, Solution
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.[Thoughts]任意一条直线都可以表述为y = ax + b假设,有两个点(x1,y1), (x2... 阅读全文

posted @ 2013-12-03 13:12 小刀初试 阅读(114) 评论(0) 推荐(0)