上一页 1 ··· 6 7 8 9 10
摘要: #-*- coding: UTF-8 -*- #Method:快慢指针法,建立虚表头,快指针走两步,慢指针走一步,若存在环,则快指针会追上慢指针# Definition for singly-linked list.# class ListNode(object):# def __init__(se 阅读全文
posted @ 2016-10-12 16:52 火金队长 阅读(170) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#从前向后遍历罗马数字,#如果某个数比前一个数小,则加上该数。反之,减去前一个数的两倍然后加上该数### 技术规则 # ##1、相同的数字连写,所表示的数等于这些数字相加得到的数,例如:III = 3##2、小的数字在大的数字右边,所表示的数等于这些数字相 阅读全文
posted @ 2016-10-12 16:51 火金队长 阅读(113) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- #Method1 :超时#class Solution(object):# def maxProfit(self, prices):# # maxprofit=0# for i in xrange(1,len(prices)):# tmprofit=pr 阅读全文
posted @ 2016-10-12 16:50 火金队长 阅读(241) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#杨辉三角返回给定行#方法:自上而下考虑问题,从给定的一行计算出下一行,则给定行数之后,计算的最后一行就是求解的最后一行class Solution(object): def getRow(self, rowIndex): """ :type rowInd 阅读全文
posted @ 2016-10-12 16:49 火金队长 阅读(114) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#杨辉三角class Solution(object): def generate(self, numRows): """ :type numRows: int :rtype: List[List[int]] """ result=[];row=1 whi 阅读全文
posted @ 2016-10-12 16:48 火金队长 阅读(123) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#平衡二叉树# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# sel 阅读全文
posted @ 2016-10-12 16:46 火金队长 阅读(200) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- # Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.rig 阅读全文
posted @ 2016-10-12 16:45 火金队长 阅读(311) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#广度优先遍历# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# se 阅读全文
posted @ 2016-10-12 16:44 火金队长 阅读(130) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.righ 阅读全文
posted @ 2016-10-12 16:43 火金队长 阅读(209) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10