自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(28)
  • 资源 (1)
  • 收藏
  • 关注

原创 LintCode:不同的路径II

LintCode:不同的路径IIclass Solution: """ @param obstacleGrid: An list of lists of integers @return: An integer """ def uniquePathsWithObstacles(self, obstacleGrid): # write your

2016-05-15 17:25:32 294

原创 LintCode:不同的路径

LintCode:不同的路径class Solution: """ @param n and m: positive integer(1 <= n , m <= 100) @return an integer """ def uniquePaths(self, m, n): # write your code here ans

2016-05-14 23:23:00 283

原创 LintCode:乱序字符串

LintCode:乱序字符串Pythonclass Solution: # @param strs: A list of strings # @return: A list of strings def anagrams(self, strs): # write your code here d1 = {} d2 = {}

2016-05-13 17:20:17 273

原创 LintCode:带最小值操作的栈

LintCode:带最小值操作的栈Pythonclass MinStack(object): def __init__(self): # do some intialize if necessary self.stack = [] def push(self, number): # write yout code here

2016-05-13 16:11:27 724

原创 LintCode:用栈实现队列

LintCode:用栈实现队列Pythonclass MyQueue: def __init__(self): self.stack1 = [] self.stack2 = [] def push(self, element): # write your code here self.stack1.append(elemen

2016-05-13 14:51:35 336

原创 LintCode:二叉树的层次遍历 II

LintCode:二叉树的层次遍历 II"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param roo

2016-05-13 13:19:11 1129

原创 LintCode:重哈希

LintCode:重哈希"""Definition of ListNodeclass ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next"""class Solution: """ @param hashTable: A

2016-05-12 20:05:20 992

原创 LintCode:主元素 III

LintCode:主元素 IIIPythonclass Solution: """ @param nums: A list of integers @param k: As described @return: The majority number """ def majorityNumber(self, nums, k): # wr

2016-05-12 19:45:29 767

原创 LintCode:子数组之和

LintCode:子数组之和方法一:O(n^2)复杂度:Pythonclass Solution: """ @param nums: A list of integers @return: A list of integers includes the index of the first number and the index of the l

2016-05-12 19:35:32 683

原创 LintCode: 三数之和

LintCode: 三数之和class Solution: """ @param numbersbers : Give an array numbersbers of n integer @return : Find all unique triplets in the array which gives the sum of zero. """ def th

2016-05-12 17:45:41 395

原创 LintCode:图中两个点之间的路线

LintCode:图中两个点之间的路线Python# Definition for a Directed graph node# class DirectedGraphNode:# def __init__(self, x):# self.label = x# self.neighbors = []class Solution: """

2016-05-12 14:50:51 506

原创 LintCode:丢失的第一个正整数

LintCode:丢失的第一个正整数Pythonfrom time import sleepclass Solution: # @param A, a list of integers # @return an integer def firstMissingPositive(self, A): # write your code here i

2016-05-12 12:34:54 271

原创 LintCode:旋转字符串

LintCode:旋转字符串Pythonclass Solution: # @param s: a list of char # @param offset: an integer # @return: nothing def rotateString(self, s, offset): # write you code here i

2016-05-12 00:28:59 662

原创 LintCode:最长上升子序列

LintCode:最长上升子序列LIS转化为LCS问题,动态规划。Pythonclass Solution: """ @param nums: The integer array @return: The length of LIS (longest increasing subsequence) """ def longestIncreasingSubseq

2016-05-11 21:46:10 303

原创 LintCode:线段树的查询

LintCode:线段树的查询"""Definition of SegmentTreeNode:class SegmentTreeNode: def __init__(self, start, end, max): self.start, self.end, self.max = start, end, max self.left, self.right

2016-05-11 20:57:38 344

原创 LintCode:二叉树的层次遍历

LintCode:二叉树的层次遍历方法一:二叉树的层序遍历,需要借助两个栈空间。"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None""""""Definition of

2016-05-11 18:27:11 513 1

原创 LintCode:Swap Two Nodes in Linked List

LintCode:Swap Two Nodes in Linked List# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: # @param {

2016-05-11 16:05:16 453

原创 LintCode:中位数

LintCode:中位数Pythonclass Solution: """ @param nums: A list of integers. @return: An integer denotes the middle number of the array. """ def median(self, nums): # write your c

2016-05-11 14:16:52 1317

原创 LintCode:落单的数 III

LintCode:落单的数 IIIPythonclass Solution: """ @param A : An integer array @return : Two integer """ def singleNumberIII(self, A): # write your code here A = sorted(A)

2016-05-10 22:34:22 405

原创 LintCode:空格替换

LintCode:空格替换注意事项如果使用 Java 或 Python, 程序中请用字符数组表示字符串。Python方法一:这个方法没有使用字符数组,直接使用的字符串数组,虽然能通过,但是不符合要求,看方法2吧。class Solution: # @param {char[]} string: An array of Char # @param {int} length: The t

2016-05-10 22:06:56 940

原创 LintCode: 矩阵归零

LintCode: 矩阵归零Pythonclass Solution: """ @param matrix: A list of lists of integers @return: Nothing """ def setZeroes(self, matrix): # write your code here row = []

2016-05-10 19:54:22 730

原创 LintCode: 将二叉树拆成链表

LintCode: 将二叉树拆成链表Python"""Definition of TreeNode:class TreeNode: def __init__(self, val): this.val = val this.left, this.right = None, None"""class Solution: # @param root:

2016-05-10 19:17:09 1009

原创 LintCode:买卖股票的最佳时机 II

LintCode:买卖股票的最佳时机 II贪心算法,只要后一天的价格大于前一天的价格就买入。Pythonclass Solution: """ @param prices: Given an integer array @return: Maximum profit """ def maxProfit(self, prices): # writ

2016-05-10 18:24:26 411

原创 LintCode:乘积最大子序列

LintCode:乘积最大子序列Pythonclass Solution: # @param nums: an integer[] # @return: an integer def maxProduct(self, nums): # write your code here if len(nums) == 0: ret

2016-05-10 17:18:45 391

原创 LintCode:x的平方根

LintCode:x的平方根Pythonclass Solution: """ @param x: An integer @return: The sqrt of x """ def sqrt(self, x): # write your code here m = x while m * m != x:

2016-05-10 12:15:54 455

原创 LintCode:在二叉查找树中插入节点

[LintCode:在二叉查找树中插入节点](http://www.lintcode.com/zh-cn/problem/insert-node-in-a-binary-search-tree/)"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val

2016-05-09 20:59:35 398

原创 LintCode:线段树的构造

LintCode:线段树的构造"""Definition of SegmentTreeNode:class SegmentTreeNode: def __init__(self, start, end): self.start, self.end = start, end self.left, self.right = None, None"""clas

2016-05-09 18:44:49 276

原创 二叉查找树中搜索区间

二叉查找树中搜索区间Python"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root: T

2016-05-09 17:08:22 366

易语言编程助手V3.1

易语言编程助手V3.1版,18年3月20号发布,非常好用,学习易语言必备。

2018-03-21

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除