自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(238)
  • 资源 (2)
  • 收藏
  • 关注

原创 leetcode -- Best Time to Buy and Sell Stock IV --难点要看

https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/参考: http://bookshadow.com/weblog/2015/02/18/leetcode-best-time-to-buy-and-sell-stock-iv/ http://www.cnblogs.com/maples7/p/4350047.html

2015-12-28 18:34:36 524

原创 leetcode -- Burst Balloons -- 重点dp

https://leetcode.com/problems/burst-balloons/类似于矩阵连乘的问题,但与house robber问题不一样。这里是2D dp,决策变量是在那个位置burst,类似于划分问题。这里dp是 bottom to up 思想。 参考:http://bookshadow.com/weblog/2015/11/30/leetcode-burst-balloons/

2015-12-28 12:50:27 4877

原创 leetcode -- Create Maximum Number -- 重点,新题

https://leetcode.com/problems/create-maximum-number/思路有点像merge sort.参考https://leetcode.com/discuss/75772/share-my-python-solution-with-explanationSo there’re 3 steps:iterate i from 0 to k.find max nu

2015-12-25 21:01:04 3994

原创 leetcode -- Count of Smaller Numbers After Self -- 经典求逆序数

https://leetcode.com/problems/count-of-smaller-numbers-after-self/思路1 merge sort关于merge sort归并排序的时候,会先一直递归到只剩下两个元素,然后对这两个元素进行merge,merge到一个临时数组。在合并的过程中就肯定有元素之间的交换,只不过这里的不是在原来数组上in place交换,而是说直接赋值到一个临时数

2015-12-25 19:46:16 9955

原创 leetcode -- Remove Invalid Parentheses--又是DFS,BFS的题目

https://leetcode.com/problems/remove-invalid-parentheses/valid parentheses definition字符串中的左右括号数应该相同,而且每个右括号左边一定有其对应的左括号思路1 DFS这里其实就是试着去remove其中一个左括号或者右括号,对于剩下的字符串,继续看remove哪一个左括号或者右括号,知道remove以及不能降低inv

2015-12-25 17:00:13 5101 2

原创 leetcode -- Range Sum Query 2D - Immutable -- 简单DP题目

https://leetcode.com/problems/range-sum-query-2d-immutable/简单DP就行。http://bookshadow.com/weblog/2015/11/12/leetcode-range-sum-query-2d-immutable/

2015-12-25 16:28:11 978 1

原创 leetcode -- 线段树理解

参考http://www.cnblogs.com/TenosDoIt/p/3453089.html http://dongxicheng.org/structure/segment-tree/ http://bookshadow.com/weblog/2015/08/13/segment-tree-set-1-sum-of-given-range/Note”对于包含n个叶子节点的完全二叉树,它

2015-12-25 12:45:03 1947

原创 leetcode -- Find Median from Data Stream -- 设计题重点

https://leetcode.com/problems/find-median-from-data-stream/利用minHeap以及maxHeap。把一个ordered num list, 分成两半A1 A2,或者其中一半比另一半长度多1,那么A1可以维护一个maxHeap,顶部就是最大值,即最靠近中间的值;A2可以维护一个minHeap,顶部就是最小值,也就是最靠近中间的值。参考http:

2015-12-25 10:58:32 691

原创 leetcode -- The Skyline Problem -- 难理解,关于heap

https://leetcode.com/problems/the-skyline-problem/基本没理解,再看看思路1 divide and conquerhttp://www.geeksforgeeks.org/divide-and-conquer-set-7-the-skyline-problem/ code参考 http://blog.csdn.net/pointbreak1/art

2015-12-24 23:28:44 1096

原创 leetcode -- Contains Duplicate III -- 重点,medium题目

https://leetcode.com/problems/contains-duplicate-iii/思路1 sorting参考http://yucoding.blogspot.hk/2015/10/leetcode-question-contains-duplicate-iii.html思路2 sliding windows参考http://bookshadow.com/weblog/2015

2015-12-24 23:16:55 478

原创 leetcode -- Course Schedule I && II -- TopSort重点

https://leetcode.com/problems/course-schedule/关于graph的题目,考察拓扑排序Course Schedule这里只要判断是否能拓扑排序就行,就是看graph内有没有环,是不是DAG。拓扑排序 参考http://blog.csdn.net/dm_vincent/article/details/7714519,思路1 Kahn算法http://songle

2015-12-24 20:43:34 712

原创 leetcode -- Dungeon Game -- dp重点,典型题

https://leetcode.com/problems/dungeon-game/dp典型题目。table filling 问题, 跟这些一起看https://leetcode.com/problems/unique-paths/ https://leetcode.com/problems/minimum-path-sum/这里dp[i][j] 要从dp[len(n)][len(m)]开始递

2015-12-24 19:37:51 520

原创 leetcode -- Add and Search Word - Data structure design -- 重点

https://leetcode.com/problems/add-and-search-word-data-structure-design/同样是关于trie.只是在search的时候要dfs backtracking 参考http://yucoding.blogspot.hk/2015/07/leetcode-question-add-and-search-word.htmlclass Tr

2015-12-24 17:34:11 516

原创 leetcode -- Implement Trie (Prefix Tree) -- 关于字典树,重要

https://leetcode.com/problems/implement-trie-prefix-tree/关于字典树介绍http://www.cnblogs.com/tanky_woo/archive/2010/09/24/1833717.html方便word的插入,搜索。看code就知道思路了。参考http://yucoding.blogspot.hk/2015/06/leetcode-q

2015-12-24 16:58:32 632

原创 leetcode -- Fraction to Recurring Decimal -- 数学题,知道相除规则

https://leetcode.com/problems/fraction-to-recurring-decimal/参考 http://yucoding.blogspot.hk/2015/03/leetcode-question-fraction-to-recurring.html 的计算方法。思路见codeclass Solution: # @return a string

2015-12-24 14:00:55 613

原创 leetcode -- Maximum Gap -- 与distributed sorting有关,重点复习一下

https://leetcode.com/problems/maximum-gap/sort 算法除了比较算法之外,还有distributed sort,时间效率可以优于O(nlogn),甚至可以达到O(n).包括couting sort, bucket sort, radix sort.复习这三种的原理。 参考https://www.byvoid.com/blog/sort-radix这里对于b

2015-12-24 12:22:25 504

原创 leetcode -- Max Points on a Line -- 重点

https://leetcode.com/problems/max-points-on-a-line/思路很简单,就是找出两两点的pair,看有多少pair的slope是一样的。这里设想plane中有一条line就是我们要求的最多点的line,那么只要我们循环到这条line上的任意一个点,那么就可以找到与其共线的其他所有点,所以每次做二维循环,都reset一个dict,然后求这个dict中的max

2015-12-23 22:49:23 470

原创 leetcode -- LRU Cache -- 重点

https://leetcode.com/problems/lru-cache/这里参考http://www.cnblogs.com/zuoyuan/p/3701572.html,思路比较清晰。用double linkedlist and hashmap

2015-12-23 22:29:21 406

原创 leetcode -- Longest Consecutive Sequence -- 重点

https://leetcode.com/problems/longest-consecutive-sequence/思路很简单。看http://www.cnblogs.com/zuoyuan/p/3765546.html http://chaoren.is-programmer.com/posts/42924.htmlcodeclass Solution(object): def lon

2015-12-23 21:48:57 404

原创 leetcode -- Binary Tree Maximum Path Sum -- 重要

https://leetcode.com/problems/binary-tree-maximum-path-sum/递归题目。值得回味。这里对每个node的path要分为两种,一种是以这个node为起点的path,有三条,root.val, root.val + root.leftpath, root.val + root.rightpath ;第二种就是经过这个node的path,即 root.

2015-12-23 21:32:46 518

原创 leetcode -- Distinct Subsequences -- DP重点

https://leetcode.com/problems/distinct-subsequences/这种两个string的题目,套路都一样。用dp 讨论 dp[i][j] 关于s[:i-1]与t[:j-1]的递推关系。并且还要求初始状态dp[i][0]以及dp[0][j]思路参考http://www.cnblogs.com/zuoyuan/p/3767256.html解题思路:这道题使用动态规划

2015-12-23 20:19:58 541

原创 leetcode -- Find the Duplicate Number-- 经典重点

https://leetcode.com/problems/find-the-duplicate-number/思路1 BShttp://bookshadow.com/weblog/2015/09/28/leetcode-find-duplicate-number/ http://www.cnblogs.com/grandyang/p/4843654.html利用抽屉原理,注意这里low就是最后的

2015-12-23 17:50:39 898

原创 leetcode -- Maximal Rectangle -- 重点

https://leetcode.com/problems/maximal-rectangle/这里思路很重要,是重点。就是把每一行转化成上一题求histogram最大矩形的题目来做。这里每一个行的,每一个元素的直方图就是往上数**连续**1的个数。求连续1可以先求一次,存入到ones数组里面,再scan的时候fetch就行。也可以像下面的code一样,每求一次用一次。思路参考:http://www

2015-12-23 16:55:02 1010

原创 leetcode -- Largest Rectangle in Histogram -- 重点,多看几遍

https://leetcode.com/problems/largest-rectangle-in-histogram/重点!!用到了递增栈,increasing stack思路参考http://blog.csdn.net/u013027996/article/details/43198421 http://tech-wonderland.net/blog/leetcode-largest-re

2015-12-23 16:06:18 470

原创 leetcode -- Minimum Window Substring -- 重点,应该会考

https://leetcode.com/problems/minimum-window-substring/思路: 解题思路:双指针思想,尾指针不断往后扫,当扫到有一个窗口包含了所有T的字符,然后再收缩头指针,直到不能再收缩为止。最后记录所有可能的情况中窗口最小的。思路很好理解,复习的时候再做一下。参考:http://www.cnblogs.com/zuoyuan/p/3785421.html

2015-12-22 21:31:45 1178

原创 leetcode -- Interleaving String -- 2D dp经典

https://leetcode.com/problems/interleaving-string/重要。思路:http://www.cnblogs.com/zuoyuan/p/3767650.html 动态规划。dp[i][j]表示s1[0…i-1]和s2[0…j-1]是否可以拼接为s3[0…i+j-1],可以拼接为true,不可以拼接为false。

2015-12-22 21:26:09 427

原创 leetcode -- Scramble String -- 重点

https://leetcode.com/problems/scramble-string/思路1 递归参考:http://www.cnblogs.com/zuoyuan/p/3777383.html http://blog.csdn.net/fightforyourdream/article/details/17707187要先排序,否则不能过OJ思路2 三维DPhttp://blog.csdn

2015-12-22 21:20:44 530

原创 leetcode -- Text Justification -- string操作的题目,思路简单,但是难以写对

https://leetcode.com/problems/text-justification/参考http://blog.csdn.net/fightforyourdream/article/details/17461861 http://www.cnblogs.com/zuoyuan/p/3782107.html 思路很直观,不要出错就行。复习的时候再coding一下

2015-12-22 20:45:56 515

原创 leetcode -- Valid Number -- Math难题,要用自动机,可以先不看

https://leetcode.com/problems/valid-number/参考http://www.cnblogs.com/zuoyuan/p/3703075.html

2015-12-22 20:34:12 916

原创 leetcode -- Insert Interval -- 重点

https://leetcode.com/problems/insert-interval/跟https://leetcode.com/problems/merge-intervals/ 一起看最简单的方法是将要插入的区间和原来的区间合在一起排序,然后按照merge intervals的方法来编程。参考 http://www.cnblogs.com/zuoyuan/p/3782048.html

2015-12-22 20:27:03 563

原创 leetcode -- Jump Game II -- 贪心,要看

https://leetcode.com/problems/jump-game-ii/dp 会TLE思路1 会TLE参考http://chaoren.is-programmer.com/posts/42912.html 要用贪心, 记录最远能到达的范围, 每次在这个范围内搜, 找出下一跳的最远范围, 更新最远范围和跳数。例如,[2,3,1,1,4], 这里首先maxreach = 2,那么第一步的

2015-12-22 20:23:06 729

原创 leetcode -- First Missing Positive -- 简单trick题目

https://leetcode.com/problems/first-missing-positive/思路1 swap参考http://www.cnblogs.com/AnnieKim/archive/2013/04/21/3034631.html http://chaoren.is-programmer.com/posts/42711.html通过swap, 把index = i上面放上元素

2015-12-22 20:01:06 573

原创 leetcode -- Sudoku Solver -- 经典重点

https://leetcode.com/problems/sudoku-solver/思路就是dfs,这里可以把candidates子节点看做所有的点,然后判断if == ‘.’,也可以只scan 一遍9*9的board。方法一参考 http://www.cnblogs.com/zuoyuan/p/3770271.html def solveSudoku(self, board):

2015-12-22 19:24:10 514

原创 leetcode -- Longest Valid Parentheses

https://leetcode.com/problems/longest-valid-parentheses/ 思路:注意这里是要找的是最长的parenthese的substring,而不是所有匹配的括号有多少对。这里考虑几个情况:)))))()()())))))()()(((())))分别讨论就能理解下述代码class Solution: # @param s, a string

2015-12-22 17:18:42 787

原创 leetcode -- Substring with Concatenation of All Words -- 思路简单,再做一遍

https://leetcode.com/problems/substring-with-concatenation-of-all-words/思路很容易,写对不容易。再做一遍http://www.cnblogs.com/zuoyuan/p/3779978.html

2015-12-22 16:34:55 465

原创 leetcode -- Reverse Nodes in k-Group -- 经典题目,要重写

https://leetcode.com/problems/reverse-nodes-in-k-group/思路很简单,复习的时候再写一遍 http://www.cnblogs.com/zuoyuan/p/3785555.htmlhttp://www.cnblogs.com/lichen782/p/leetcode_Reverse_Nodes_in_kGroup.html

2015-12-22 16:26:16 502

原创 leetcode -- Integer to Roman -- 重点

https://leetcode.com/problems/integer-to-roman/http://www.cnblogs.com/zuoyuan/p/3779581.html看code: values = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] numerals = [ "M", "CM

2015-12-22 16:00:40 415

原创 leetcode -- Wildcard Matching --再看

https://leetcode.com/problems/wildcard-matching/参考:http://www.cnblogs.com/zuoyuan/p/3781872.htmlhttp://yucoding.blogspot.hk/2013/02/leetcode-question-123-wildcard-matching.html用two pointers的方法

2015-12-22 15:46:31 496

原创 leetcode -- Regular Expression Matching -- dp 重点

https://leetcode.com/problems/regular-expression-matching/trick: 如果有两个str list, 考虑用2D dp[i][j]思路1 递归pyton TLE思路2: dp思路参考http://bangbingsyb.blogspot.hk/2014/11/leetcode-regular-expression-matching.html关

2015-12-22 15:22:35 721

原创 leetcode -- Super Ugly Number -- 跟ugly number系列一起复习

https://leetcode.com/problems/super-ugly-number/ https://leetcode.com/problems/ugly-number-ii/ 参考 http://bookshadow.com/weblog/2015/12/03/leetcode-super-ugly-number/

2015-12-22 12:01:11 3243

基于风险决策的企业管理分析

2010年西北工业大学数学建模校队暑假训练题----2010年东北A题

2010-07-22

温室中的绿色生态臭氧病虫害防治

2010年西北工业大学数模校队训练题----第七届苏北B题

2010-07-18

空空如也

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

TA关注的人

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