<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[leetcodecl]]></title><description><![CDATA[leetcode刷题进步]]></description><link>https://blog.youkuaiyun.com/leetcodecl</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; leetcodecl]]></copyright><item><title><![CDATA[##拼凑面额##]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/88199530</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/88199530</guid><author>leetcodecl</author><pubDate>Tue, 05 Mar 2019 19:52:21 +0800</pubDate><description><![CDATA[题目描述

给你六种面额1、5、10、20、50、100元的纸币，假设每种币值的数量都足够多，编写程序求组成N元（N为0-10000的非负整数）的不同组合的个数。

输入描述:


输入为一个数字N，即需要拼凑的面额

输出描述:


输出也是一个数字，为组成N的组合个数。

示例1

输入

复制


5


输出

复制


2

解法上类比于“0/1背包”问题：

table[i,j]表示使...]]></description><category></category></item><item><title><![CDATA[#### 146. LRU Cache  ####]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/88141725</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/88141725</guid><author>leetcodecl</author><pubDate>Mon, 04 Mar 2019 22:06:18 +0800</pubDate><description><![CDATA[Design and implement a data structure forLeast Recently Used (LRU) cache. It should support the following operations:getandput.

get(key)- Get the value (will always be positive) of the key if th...]]></description><category></category></item><item><title><![CDATA[二叉树的下一个结点]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/86485213</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/86485213</guid><author>leetcodecl</author><pubDate>Mon, 14 Jan 2019 22:40:11 +0800</pubDate><description><![CDATA[给定一个二叉树和其中的一个结点，请找出中序遍历顺序的下一个结点并且返回。注意，树中的结点不仅包含左右子结点，同时包含指向父结点的指针。

方法：

首先，判断pNode节点是否存在右孩子，若存在则遍历右孩子，找到右孩子的最左节点；

否则，从root出发，向上遍历，直到节点pre是其父节点的左孩子为止。

 


/*
struct TreeLinkNode {
    int val;
    ...]]></description><category></category></item><item><title><![CDATA[旋转数组的最小数字]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/86485181</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/86485181</guid><author>leetcodecl</author><pubDate>Mon, 14 Jan 2019 22:35:18 +0800</pubDate><description><![CDATA[把一个数组最开始的若干个元素搬到数组的末尾，我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转，输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转，该数组的最小值为1。 NOTE：给出的所有元素都大于0，若数组大小为0，请返回0。

方法：二分法的变形


class Solution {
public:
    int minNumberInRota...]]></description><category></category></item><item><title><![CDATA[23. Merge k Sorted Lists]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/85691190</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/85691190</guid><author>leetcodecl</author><pubDate>Thu, 03 Jan 2019 13:34:45 +0800</pubDate><description><![CDATA[Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

Example:


Input:
[
  1-&amp;gt;4-&amp;gt;5,
  1-&amp;gt;3-&amp;gt;4,
  2-&amp;gt;6
]
Output: 1-&amp;gt;1-&amp;gt;2-&amp;gt;3-&amp;gt;4-...]]></description><category></category></item><item><title><![CDATA[229. Majority Element II]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/85320230</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/85320230</guid><author>leetcodecl</author><pubDate>Fri, 28 Dec 2018 12:43:48 +0800</pubDate><description><![CDATA[Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.

Note: The algorithm should run in linear time and in O(1) space.

Example 1:


Input: [3,2,3]
Output: [3]

Exa...]]></description><category></category></item><item><title><![CDATA[673. Number of Longest Increasing Subsequence]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/85255420</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/85255420</guid><author>leetcodecl</author><pubDate>Tue, 25 Dec 2018 22:50:57 +0800</pubDate><description><![CDATA[Given an unsorted array of integers, find the number of longest increasing subsequence.

Example 1:


Input: [1,3,5,4,7]
Output: 2
Explanation: The two longest increasing subsequence are [1, 3, 4, 7] ...]]></description><category></category></item><item><title><![CDATA[188. Best Time to Buy and Sell Stock IV]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/85240390</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/85240390</guid><author>leetcodecl</author><pubDate>Mon, 24 Dec 2018 23:07:31 +0800</pubDate><description><![CDATA[Say you have an array for which the ith element is the price of a given stock on day i.

Design an algorithm to find the maximum profit. You may complete at most k transactions.

Note:
You may not eng...]]></description><category></category></item><item><title><![CDATA[see-123. Best Time to Buy and Sell Stock III]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/85240103</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/85240103</guid><author>leetcodecl</author><pubDate>Mon, 24 Dec 2018 22:31:27 +0800</pubDate><description><![CDATA[Say you have an array for which the ith element is the price of a given stock on day i.

Design an algorithm to find the maximum profit. You may complete at most two transactions.

Note: You may not e...]]></description><category></category></item><item><title><![CDATA[末尾0的个数]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/84727090</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/84727090</guid><author>leetcodecl</author><pubDate>Sun, 02 Dec 2018 20:06:03 +0800</pubDate><description><![CDATA[题目描述

输入一个正整数n,求n!(即阶乘)末尾有多少个0？ 比如: n = 10; n! = 3628800,所以答案为2

输入描述:


输入为一行，n(1 ≤ n ≤ 1000)

输出描述:


输出一个整数,即题目所求

示例1

输入

复制


10

输出

复制


2

解析：

能被5（5^1）整除的提供1个0

能被25（5^2）整除的提供2个0

能被125（5^3）...]]></description><category></category></item><item><title><![CDATA[[数串*]]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/84555169</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/84555169</guid><author>leetcodecl</author><pubDate>Mon, 26 Nov 2018 19:46:23 +0800</pubDate><description><![CDATA[题目描述

设有n个正整数，将他们连接成一排，组成一个最大的多位整数。
如:n=3时，3个整数13,312,343,连成的最大整数为34331213。
如:n=4时,4个整数7,13,4,246连接成的最大整数为7424613。

输入描述:


有多组测试样例，每组测试样例包含两行，第一行为一个整数N（N&amp;lt;=100），第二行包含N个数(每个数不超过1000，空格分开)。

输出描述:


...]]></description><category></category></item><item><title><![CDATA[最短排序]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/83618594</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/83618594</guid><author>leetcodecl</author><pubDate>Thu, 01 Nov 2018 12:57:34 +0800</pubDate><description><![CDATA[题目描述

对于一个无序数组A，请设计一个算法，求出需要排序的最短子数组的长度。

给定一个整数数组A及它的大小n，请返回最短子数组的长度。

测试样例：


[1,5,3,4,2,6,7],7


返回：4


class ShortSubsequence {
public:
    int findShortest(vector&amp;lt;int&amp;gt; A, int n) {
        /...]]></description><category></category></item><item><title><![CDATA[【360】挑选镇长]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/83618521</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/83618521</guid><author>leetcodecl</author><pubDate>Thu, 01 Nov 2018 12:47:20 +0800</pubDate><description><![CDATA[题目描述

360员工桂最近申请了一个长假，一个人背着包出去自助游了。
　　路上，他经过了一个小镇，发现小镇的人们都围在一棵树下争吵。桂上前询问情况，得知小镇的人们正缺一个镇长，他们希望能选一个知名又公正的镇长，即，大家希望能选出一个人，所有人都认识他，但同时他不认识镇上除自己以外的其他人（在此，我们默认每个人自己认识自己）。可是小镇里的人太多了，一下子大家谁也说服不了谁。
　　“这简单啊。”桂表...]]></description><category></category></item><item><title><![CDATA[顺时针打印矩阵]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/83421667</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/83421667</guid><author>leetcodecl</author><pubDate>Fri, 26 Oct 2018 22:30:03 +0800</pubDate><description><![CDATA[题目描述

对于一个矩阵，请设计一个算法从左上角(mat[0][0])开始，顺时针打印矩阵元素。

给定int矩阵mat,以及它的维数nxm，请返回一个数组，数组中的元素为矩阵元素的顺时针输出。

测试样例：


[[1,2],[3,4]],2,2


返回：[1,2,4,3]




class Printer {
public:
    vector&amp;lt;int&amp;gt; clockwiseP...]]></description><category></category></item><item><title><![CDATA[【上高楼***】]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/83245327</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/83245327</guid><author>leetcodecl</author><pubDate>Sun, 21 Oct 2018 21:06:53 +0800</pubDate><description><![CDATA[题目描述

现在有一栋高楼，但是电梯却出了故障，无奈的你只能走楼梯上楼，根据你的腿长，你一次能走1级或2级楼梯，已知你要走n级楼梯才能走到你的目的楼层，请计算你走到目的楼层的方案数，由于楼很高，所以n的范围为int范围内的正整数。

给定楼梯总数n，请返回方案数。为了防止溢出，请返回结果Mod 1000000007的值。

测试样例：


3


返回：3

使用快速幂运算的算法原理实现斐波那契数...]]></description><category></category></item><item><title><![CDATA[【网易】小易的升级之路]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/83097125</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/83097125</guid><author>leetcodecl</author><pubDate>Tue, 16 Oct 2018 20:43:31 +0800</pubDate><description><![CDATA[题目描述

小易经常沉迷于网络游戏.有一次,他在玩一个打怪升级的游戏,他的角色的初始能力值为 a.在接下来的一段时间内,他将会依次遇见n个怪物,每个怪物的防御力为b1,b2,b3...bn. 如果遇到的怪物防御力bi小于等于小易的当前能力值c,那么他就能轻松打败怪物,并 且使得自己的能力值增加bi;如果bi大于c,那他也能打败怪物,但他的能力值只能增加bi 与c的最大公约数.那么问题来了,在一系列...]]></description><category></category></item><item><title><![CDATA[【腾讯】微信红包]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/83065880</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/83065880</guid><author>leetcodecl</author><pubDate>Mon, 15 Oct 2018 22:27:36 +0800</pubDate><description><![CDATA[题目描述

春节期间小明使用微信收到很多个红包，非常开心。在查看领取红包记录时发现，某个红包金额出现的次数超过了红包总数的一半。请帮小明找到该红包金额。写出具体算法思路和代码实现，要求算法尽可能高效。

给定一个红包的金额数组gifts及它的大小n，请返回所求红包的金额。

若没有金额超过总数的一半，返回0。

测试样例：


[1,2,3,2,2],5


返回：2

 


class Gif...]]></description><category></category></item><item><title><![CDATA[【楚楚街】解密]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/83025620</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/83025620</guid><author>leetcodecl</author><pubDate>Fri, 12 Oct 2018 13:31:26 +0800</pubDate><description><![CDATA[题目描述

亮亮深吸一口气，小心地将盒子打开，里面是一张地图，地图上除了一些奇怪的字母以外没有任何路线信息，这可让亮亮犯了愁，这些字母代表了什么意思呢？ 亮亮绞尽脑汁也想不出什么思路，突然，亮亮眼前一亮，“我可以把这些字母所有的排列方式全部写出来，一定可以找到答案！” 于是，亮亮兴奋的开始寻找字母里的秘密。

输入描述:


每组数据输入只有一行，是一个由不同的大写字母组成的字符串，已知字符串的长...]]></description><category></category></item><item><title><![CDATA[【蘑菇街】投篮游戏]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/83025433</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/83025433</guid><author>leetcodecl</author><pubDate>Fri, 12 Oct 2018 13:11:07 +0800</pubDate><description><![CDATA[题目描述

有一个投篮游戏。球场有p个篮筐，编号为0，1...，p-1。每个篮筐下有个袋子，每个袋子最多装一个篮球。有n个篮球，每个球编号xi 。规则是将数字为xi 的篮球投到xi 除p的余数为编号的袋里。若袋里已有篮球则球弹出游戏结束输出i，否则重复至所有球都投完。输出-1。问游戏最终的输出是什么？

输入描述:


第一行两个整数p,n（2≤p,n≤300)。p为篮筐数，n为篮球数。接着n行为...]]></description><category></category></item><item><title><![CDATA[【蘑菇街】最大间隔]]></title><link>https://blog.youkuaiyun.com/leetcodecl/article/details/83018748</link><guid>https://blog.youkuaiyun.com/leetcodecl/article/details/83018748</guid><author>leetcodecl</author><pubDate>Thu, 11 Oct 2018 20:58:34 +0800</pubDate><description><![CDATA[题目描述

给定一个递增序列，a1 &amp;lt;a2 &amp;lt;...&amp;lt;an 。定义这个序列的最大间隔为d=max{ai+1 - ai}(1≤i&amp;lt;n),现在要从a2 ,a3 ..an-1 中删除一个元素。问剩余序列的最大间隔最小是多少？

输入描述:


第一行，一个正整数n(1&amp;lt;=n&amp;lt;=100),序列长度;接下来n个小于1000的正整数，表示一个递增序列。

输出描述:


输...]]></description><category></category></item></channel></rss>