自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LintCode:背包问题

LintCode:背包问题动态规划,同样的算法,Python超时,JAVA通过,真是搞不明白,难道Python的效率真的如此之低吗。。。Pythonclass Solution: # @param m: An integer m denotes the size of a backpack # @param A: Given n items with size A[i] #

2016-09-17 00:31:53 836

原创 LintCode: 房屋染色 II

LintCode: 房屋染色 II先用朴素的动态规划,状态转移方程 ans[i][j] = min(ans[i-1][j]+cost[i][k], ans[i][j]) 89%时提示超时。class Solution: # @param {int[][]} costs n x k cost matrix # @return {int} an integer, the minimu

2016-09-15 00:44:52 1107 1

原创 LintCode:最长连续序列

LintCode:最长连续序列题目要求O(n)复杂度,我这个算法虽然通过了,但是排序操作至少就是O(nlgn)的复杂度了,额,还得再想想。class Solution: """ @param num, a list of integer @return an integer """ def longestConsecutive(self, num):

2016-09-14 00:27:41 552

原创 LintCode:最接近的三数之和

LintCode:最接近的三数之和class Solution: """ @param numbers: Give an array numbers of n integer @param target : An integer @return : return the sum of the three integers, the sum closest target

2016-09-14 00:08:41 628

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

LintCode:买卖股票的最佳时机 III直接暴力拆分成一前一后两个数组,分别求解,可惜超时,暂时还没想到更好的解法,容我再想想。class Solution: """ @param prices: Given an integer array @return: Maximum profit """ def maxProfit(self, prices):

2016-09-12 23:55:59 933

原创 LintCode:排列序号

LintCode:排列序号参考一个很巧妙的想法,源地址在这里class Solution: # @param {int[]} A an integer array # @return {long} a long integer def permutationIndex(self, A): # Write your code here n = l

2016-09-11 12:57:58 396

原创 LintCode: 连续子数组求和

LintCode: 连续子数组求和需要考虑很多种情况,也是看了数据才知道逻辑哪里不对,感觉自己考虑问题很不全面。import copyclass Solution: # @param {int[]} A an integer array # @return {int[]} A list of integers includes the index of the #

2016-09-11 00:44:16 533

原创 LintCode: 最小子数组

LintCode: 最小子数组class Solution: """ @param nums: a list of integers @return: A integer denote the sum of minimum subarray """ def minSubArray(self, nums): # write your code h

2016-09-08 00:28:38 449

原创 LintCode:删除二叉查找树的节点

LintCode:删除二叉查找树的节点"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""class Solution: """ @param root

2016-09-08 00:07:38 624

原创 LintCode:不同的二叉查找树

LintCode:不同的二叉查找树思路见这篇博客class Solution: # @paramn n: An integer # @return: An integer def numTrees(self, n): # write your code here dp = [1 for i in range(n+1)] for

2016-09-07 00:29:32 338

原创 LintCode:完美平方

LintCode:完美平方public class Solution { /** * @param n a positive integer * @return an integer */ public int numSquares(int n) { // Write your code here int[] dp = n

2016-09-06 00:21:55 918 1

原创 LintCode:重排链表

LintCode:重排链表思路比较简单,就是先把链表分成两段,然后把后半段反转,然后依次插入前半段的链表中。import copy"""Definition of ListNodeclass ListNode(object): def __init__(self, val, next=None): self.val = val self.next = ne

2016-09-04 22:54:43 569

原创 LintCode: 和大于S的最小子数组

LintCode: 和大于S的最小子数组一前一后两根指针,当当前数组的和大于s时,移动前面的指针直到和小于s为止,比较当前数组长度与ans的大小。class Solution: # @param nums: a list of integers # @param s: an integer # @return: an integer representing the m

2016-09-04 20:01:58 761 1

原创 LintCode:数字组合

LintCode:数字组合回溯算法,注意在最后要清除上一次的状态。import copyclass Solution: # @param candidates, a list of integers # @param target, integer # @return a list of lists of integers def combinationSum(se

2016-09-03 16:47:17 337

原创 LintCode:搜索二维矩阵 II

LintCode:搜索二维矩阵 IIclass Solution: """ @param matrix: An list of lists of integers @param target: An integer you want to search in matrix @return: An integer indicates the total occurren

2016-09-03 00:35:28 283

原创 LintCode:滑动窗口的最大值

LintCode:滑动窗口的最大值class Solution: """ @param nums: A list of integers. @return: The maximum number inside the window at each moving. """ def maxSlidingWindow(self, nums, k):

2016-09-02 00:34:24 297

原创 LintCode:最近公共祖先

LintCode:最近公共祖先"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""import copyclass Solution: """ @pa

2016-09-01 00:21:06 578

易语言编程助手V3.1

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

2018-03-21

空空如也

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

TA关注的人

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