![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
ChessC
这个作者很懒,什么都没留下…
展开
-
[LEETCODE][305. Number of Islands II]
先来看一下题目描述:305.Number of Islands IIA 2d grid map ofmrows andncolumns is initially filled with water. We may perform anaddLandoperation which turns the water at position (row, col) into a la...原创 2019-05-22 16:30:20 · 142 阅读 · 0 评论 -
[LEETCODE][694. Number of Distinct Islands]
题目描述694.Number of Distinct IslandsGiven a non-empty 2D arraygridof 0's and 1's, anislandis a group of1's (representing land) connected 4-directionally (horizontal or vertical.) You may assu...原创 2019-05-17 10:51:12 · 175 阅读 · 0 评论 -
[LEETCODE][289. Game of Life][in-place方法,思想很好]
之前碰到的一题:289.Game of LifeAccording to theWikipedia's article: "TheGame of Life, also known simply asLife, is a cellular automaton devised by the British mathematician John Horton Conway in 197...原创 2019-04-18 16:12:08 · 408 阅读 · 0 评论 -
[Backtracking]Algorithm+[LEETCODE]examples汇总
递归回溯也是经常用到的,最近重新看了两道,归纳一下吧。对于此类的问题,关键点是找递归开始即回溯回来的点。例如:对于数组问题,典型的这个点可以是:(1)index是否到末尾了?(2)当前元素是否进行使用过了?话不多说,看下面三类典型的1.求子集和的问题注意几道求子集和的问题的区别,解法大体都是类似的,用递归回溯的方法39.Combination Sum给定数组中的数字是...原创 2019-02-13 11:00:32 · 138 阅读 · 0 评论 -
DP[dynamic programming]问题汇总分析解答(二)
矩阵DP这一类的DP问题个人觉得是比较简单的一类,基本方法归结为下:1.明确dp[i][j]位置代表的内容,可以为到当前为止的累加和;当前位置的方法总数等等2.明确当前的(i,j)位置可由之前的哪一种状态变化而来,例如很多矩阵情况下会限定向下或者向右走。3.明确上述几点之后我觉得没什么好说的了,注意边界的处理即可,往往是最上一行及最左一列4.还有一点和之前的两个序列不同的是,...原创 2019-01-16 20:09:01 · 197 阅读 · 0 评论 -
DP[dynamic programming]问题汇总分析解答(一)
DP的问题也是绕不开啊,基本思想从0-1背包而来,已经进行过总结了。其他还有好多种的变形,一种种来归纳吧(一)两个序列的DP问题(给定两个string)这类的题目总结后以下述几步解决即可。1.在两个序列的情况下,往往是用二维DPvector<vector<int>> dp(m+1,vector<int>(n+1,0);2.然后进行初始化,...原创 2019-01-16 15:12:11 · 450 阅读 · 0 评论 -
Trie[字典树]详细总结及例题[给定题解AC beats>=90%]
1. Trie树Trie树,即字典树,又称单词查找树或键树,是一种树形结构,是一种哈希树的变种。典型应用是用于统计和排序大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计。它的优点是:最大限度地减少无谓的字符串比较,查询效率比哈希表高。Trie的核心思想是空间换时间。利用字符串的公共前缀来降低查询时间的开销以达到提高效率的目的。它有3个基本性质:1.根节点不...原创 2019-01-17 15:07:12 · 254 阅读 · 0 评论 -
leetcode638及STL中inner_product
遇到No.638题,总结一下看到的discuss中用的比较好的两点题目描述:In LeetCode Store, there are some kinds of items to sell. Each item has a price.However, there are some special offers, and a special offer consists of one...原创 2018-11-07 15:22:56 · 233 阅读 · 0 评论 -
LEETCODE上买卖stock问题汇总解
NO.1121.Best Time to Buy and Sell Stock限定只能够买卖一次。思路:因为只能买卖一次,因此我们用两个变量,buy表示买入价格,profit表示卖出后所赚的差价,buy不断取数组中元素的最小值,而profit我们取初始化时profit=0和prices[i]-buy中的最大值。class Solution {public: int ...原创 2018-08-21 15:40:19 · 1118 阅读 · 1 评论 -
[LEETCODE][975. Odd Even Jump]
题目描述:You are given an integer arrayA. Fromsome starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...)jumps in the series are calledodd numbered jumps, and the (2nd, 4th, 6th...原创 2019-06-05 10:49:31 · 163 阅读 · 0 评论