LeetCode
杰Tang_fighting
这个作者很懒,什么都没留下…
展开
-
LeetCode-Evaluate Reverse Polish Notation (Python)
【问题】Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples:原创 2014-06-22 21:09:06 · 843 阅读 · 0 评论 -
LeetCode-Sort List(Python)
【问题】Sort a linked list in O(n log n) time using constant space complexity.【代码】# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x#原创 2014-06-27 17:12:11 · 842 阅读 · 0 评论 -
LeetCode-Max Points on a Line (Python)
【问题】Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.【思路】对每一个点,分别计算这个点和其他所有点构成的斜率,具有相同斜率最多的点所构成的直线,就是具有最多点的直线。【代码】class Point: def __in原创 2014-06-22 22:33:26 · 991 阅读 · 0 评论 -
LeetCode-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".【代码】class Solution: # @param s, a string # @retu原创 2014-06-22 20:29:57 · 879 阅读 · 0 评论 -
LeetCode-Insertion Sort List (Python)
【问题】Sort a linked list using insertion sort.【代码】# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Sol原创 2014-06-27 19:42:39 · 768 阅读 · 0 评论