Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
luzhipeng committed May 18, 2019
1 parent 163899d commit 48bc053
Show file tree
Hide file tree
Showing 22 changed files with 356 additions and 112 deletions.
23 changes: 0 additions & 23 deletions 172.factorial-trailing-zeroes.js

This file was deleted.

23 changes: 0 additions & 23 deletions 263.ugly-number.js

This file was deleted.

43 changes: 0 additions & 43 deletions 342.power-of-four.js

This file was deleted.

14 changes: 0 additions & 14 deletions 575.distribute-candies.js

This file was deleted.

18 changes: 11 additions & 7 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ The data structures mainly includes:
- [0020.Valid Parentheses](./problems/20.validParentheses.md)
- [0026.remove-duplicates-from-sorted-array](./problems/26.remove-duplicates-from-sorted-array.md)
- [0088.merge-sorted-array](./problems/88.merge-sorted-array.md)
- [0121.best-time-to-buy-and-sell-stock](./problems/121.best-time-to-buy-and-sell-stock.md) 🆕
- [0122.best-time-to-buy-and-sell-stock-ii](./problems/122.best-time-to-buy-and-sell-stock-ii.md) 🆕
- [0121.best-time-to-buy-and-sell-stock](./problems/121.best-time-to-buy-and-sell-stock.md)
- [0122.best-time-to-buy-and-sell-stock-ii](./problems/122.best-time-to-buy-and-sell-stock-ii.md)
- [0136.single-number](./problems/136.single-number.md)
- [0167.two-sum-ii-input-array-is-sorted](./problems/167.two-sum-ii-input-array-is-sorted.md)
- [0172.factorial-trailing-zeroes](./problems/172.factorial-trailing-zeroes.md) 🆕
- [0169.majority-element](./problems/169.majority-element.md)
- [0190.reverse-bits](./problems/190.reverse-bits.md)
- [0191.number-of-1-bits](./problems/191.number-of-1-bits.md)
Expand All @@ -109,24 +110,27 @@ The data structures mainly includes:
- [0206.reverse-linked-list](./problems/206.reverse-linked-list.md)
- [0219.contains-duplicate-ii](./problems/219.contains-duplicate-ii.md)
- [0226.invert-binary-tree](./problems/226.invert-binary-tree.md)
- [0263.ugly-number](./problems/263.ugly-number.md) 🆕
- [0283.move-zeroes](./problems/283.move-zeroes.md)
- [0342.power-of-four](./problems/342.power-of-four.md) 🆕
- [0349.intersection-of-two-arrays](./problems/349.intersection-of-two-arrays.md)
- [0575.distribute-candies](./problems/575.distribute-candies.md) 🆕


#### Medium

- [0002. Add Two Numbers](./problems/2.addTwoNumbers.md)
- [0003. Longest Substring Without Repeating Characters](./problems/3.longestSubstringWithoutRepeatingCharacters.md)
- [0011.container-with-most-water](./problems/11.container-with-most-water.md)
- [0015.3-sum](./problems/15.3-sum.md) 🆕
- [0015.3-sum](./problems/15.3-sum.md)
- [0019. Remove Nth Node From End of List](./problems/19.removeNthNodeFromEndofList.md)
- [0024. Swap Nodes In Pairs](./problems/24.swapNodesInPairs.md)
- [0039.combination-sum](./problems/39.combination-sum.md)
- [0040.combination-sum-ii](./problems/40.combination-sum-ii.md)
- [0046.permutations](./problems/46.permutations.md)
- [0047.permutations-ii](./problems/47.permutations-ii.md)
- [0055.jump-game](./problems/55.jump-game.md) 🆕
- [0062.unique-paths](./problems/62.unique-paths.md )🆕
- [0055.jump-game](./problems/55.jump-game.md)
- [0062.unique-paths](./problems/62.unique-paths.md )
- [0075.sort-colors](./problems/75.sort-colors.md)
- [0078.subsets](./problems/78.subsets.md)
- [0086.partition-list](./problems/86.partition-list.md)
Expand All @@ -138,12 +142,12 @@ The data structures mainly includes:
- [0103.binary-tree-zigzag-level-order-traversal](./problems/103.binary-tree-zigzag-level-order-traversal.md)
- [0139.word-break](./problems/139.word-breakmd)
- [0144.binary-tree-preorder-traversal](./problems/144.binary-tree-preorder-traversal.md)
- [0150.evaluate-reverse-polish-notation](./problems/150.evaluate-reverse-polish-notation.md) 🖊
- [0150.evaluate-reverse-polish-notation](./problems/150.evaluate-reverse-polish-notation.md)
- [0152.maximum-product-subarray](./problems/152.maximum-product-subarray.md) 🆕
- [0199.binary-tree-right-side-view](./problems/199.binary-tree-right-side-view.md)
- [0201.bitwise-and-of-numbers-range](./problems/201.bitwise-and-of-numbers-range.md)
- [0208.implement-trie-prefix-tree](./problems/208.implement-trie-prefix-tree.md)
- [0209.minimum-size-subarray-sum](./problems/209.minimum-size-subarray-sum.md) 🖊
- [0209.minimum-size-subarray-sum](./problems/209.minimum-size-subarray-sum.md)
- [0236.lowest-common-ancestor-of-a-binary-tree](./problems/236.lowest-common-ancestor-of-a-binary-tree.md)
- [0238.product-of-array-except-self](./problems/238.product-of-array-except-self.md) 🆕
- [0240.search-a-2-d-matrix-ii](./problems/240.search-a-2-d-matrix-ii.md)
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ leetcode 题解,记录自己的 leetcode 解题之路。
- [0020.Valid Parentheses](./problems/20.validParentheses.md)
- [0026.remove-duplicates-from-sorted-array](./problems/26.remove-duplicates-from-sorted-array.md)
- [0088.merge-sorted-array](./problems/88.merge-sorted-array.md)
- [0121.best-time-to-buy-and-sell-stock](./problems/121.best-time-to-buy-and-sell-stock.md) 🆕
- [0122.best-time-to-buy-and-sell-stock-ii](./problems/122.best-time-to-buy-and-sell-stock-ii.md) 🆕
- [0121.best-time-to-buy-and-sell-stock](./problems/121.best-time-to-buy-and-sell-stock.md)
- [0122.best-time-to-buy-and-sell-stock-ii](./problems/122.best-time-to-buy-and-sell-stock-ii.md)
- [0136.single-number](./problems/136.single-number.md)
- [0167.two-sum-ii-input-array-is-sorted](./problems/167.two-sum-ii-input-array-is-sorted.md)
- [0172.factorial-trailing-zeroes](./problems/172.factorial-trailing-zeroes.md) 🆕
- [0169.majority-element](./problems/169.majority-element.md)
- [0190.reverse-bits](./problems/190.reverse-bits.md)
- [0191.number-of-1-bits](./problems/191.number-of-1-bits.md)
Expand All @@ -107,8 +108,11 @@ leetcode 题解,记录自己的 leetcode 解题之路。
- [0206.reverse-linked-list](./problems/206.reverse-linked-list.md)
- [0219.contains-duplicate-ii](./problems/219.contains-duplicate-ii.md)
- [0226.invert-binary-tree](./problems/226.invert-binary-tree.md)
- [0263.ugly-number](./problems/263.ugly-number.md) 🆕
- [0283.move-zeroes](./problems/283.move-zeroes.md)
- [0342.power-of-four](./problems/342.power-of-four.md) 🆕
- [0349.intersection-of-two-arrays](./problems/349.intersection-of-two-arrays.md)
- [0575.distribute-candies](./problems/575.distribute-candies.md) 🆕


#### 中等难度
Expand Down
1 change: 1 addition & 0 deletions assets/drawio/172.factorial-trailing-zeroes.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile modified="2019-05-18T06:10:43.607Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" etag="poNqguB4ldgKHB1Otg1c" version="10.6.7" type="device"><diagram id="AfA178754VddEakG0pOT" name="第 1 页">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</diagram></mxfile>
1 change: 1 addition & 0 deletions assets/drawio/263.ugly-number.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile modified="2019-05-18T14:02:55.848Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" etag="1CmG2J_j1khV5AjXmkwd" version="10.6.7" type="device"><diagram id="NQOAA_INps-jg08JScd_" name="第 1 页">5Zhdb5swFIZ/DZepwAaSXuazvWinbW213VUOOGDFYGachu7X7xhMAqHVNi0brK3UYF5/P+fYHNvC86S4kiSLb0VIuYXssLDwwkLo0pnArxaeK8H13UqIJAsryTkKd+w7NaJt1B0Lad4qqITgimVtMRBpSgPV0oiUYt8uthG83WtGItoR7gLCu+oXFqq4UidofNSvKYviumfHv6xyElIXNjPJYxKKfUPCSwvPpRCqSiXFnHLNruZS1Vu9knsYmKSp+pUK19PpvUcWN2s0eXB3t1vnkxyNUNXKE+E7M+HDcNVzzUCKXRpS3Yxt4dk+ZoreZSTQuXswOmixSji8OZA0DVKpaPHqSJ3D/MFvqEioks9QpK7gelUV4zMONmPaHy3gGSluwK81YmweHVo+YoGEIfMblHCHkvltYYIJqzaLXEmxpXPBhQQlFSmUnG0Y5ycS4SxK4TUAQBT0mcbHwAmnJiNhYai7eRF+2zxn4I9sv82/tkeDv/sCf/S3+LtdL+3dSZFvD8tJvQFCwkOD5Hcgeb1DcocGadyB9PXtbnbYGQ9rs5u8J/qu4w2L/mX3U38KHwK5TCdZUsaOTSucwlQia6g3ZE35R5EzxYTOXQulRAIFuM6YkWAblYBrk1kIb8o/KFJ2Ns2zKsbV9En9smGFNsnMjGcRK6WD46kGgVZBmOILBuHxhoHp5EUAPaJVSBSBh9ZzeG44USMS6HHlo1LUIFaeo2nes2D7eEvkduSgyUWWRtqzRKoawxwvp/7yTC7heQPbDuujSPPL2v+n9TRIPiyT3jA53aXznqJkcNx+ty7nhcNc7256Gib376bdw1ztuQMKlPvH1D1OvOEw5DQI7H8td2Pw/z8OcX4ahywgyrjiJM8fP9O9kFtoD60g6ijgH1ImQtEBC+M04CKn/z4e6X9pdk8IFvK5Xokhe2r5iP9tp68XSzyjvLxcBXPYMP2ihFPnQyoyz7KdPCPpnzXkzZCPLQ+q2g8R1zg/7JI1LHXTA8y86qTdsXYJPYdaHeSG85qzad3cYKNzBRkeajkf9rrOhzA+y84Er8fb6DKvcaWPlz8A</diagram></mxfile>
1 change: 1 addition & 0 deletions assets/drawio/342.power-of-four.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile modified="2019-05-18T15:04:59.393Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" etag="lNo_8-8VvE59liv8tlX-" version="10.6.7" type="device"><diagram id="qBFZyUjtuOMw8SgRTH_N" name="第 1 页">7Vpdb5swFP01PFbCNjjhsUnTTZOqTerDtL5MDJwEleCUkIb21+8SbAIYJNYGjJZQKYXjjwvnXl8fGwwy36RfYne7fuA+Cw1s+qlB7gyMHTSF3wx4ywGLWjmwigM/h9AJeAzemQBNge4Dn+0qFRPOwyTYVkGPRxHzkgrmxjE/VKsteVi1unVXTAEePTdU0Z+Bn6xzdIonJ/wrC1ZraRlRJy/ZuLKyeJLd2vX5oQSRhUHmMedJfrZJ5yzMuJO85O3uW0qLG4tZlHRp8Pye/n5n7Lt98+vJf3Benr457EZ459UN9wXx8n6TN0lCwlIwMVsnmxAABKe7JObPbM5DHgMS8QhqzpZBGNYgNwxWEVx6cJMM8Nkri5MA6L0VBZvA9zMzs8M6SNjj1vUymweIJcBivo98lt2/CVfiVqEDlrZygApmISIZ37AkfoMqokHhDBGNVFweTq61BLQueVW2ckUwrYqOT3zDiaD8H+h3mui/JAcgk+r1gMwzdRdclBNsS7MTsOIES6Ef+oGk30ZSySvubpvPBMsgzWg7B2WoRpndLXFYvTFG1LCl46bM6TbS+6PMUiijI48yZGHNnNkKZwamYZYG/eC1whx92WdKZrbkUXKzO+q4W6gAj58eyZHlcLYS/4/97LZu9LmO7BkBnmxoav7gB8iv2ORL+Lnn+1hagafPDVWNA3x8DomOMuNnRAhhjOW1NGdgMlnc0sW5ZoZJNQCxo+a5AhtmaqAN8/NIHXUGB9BaBphoFqho0iSPLod/hHTr08YV2iV5gOoWp+oiDY9LNtgfW9X2phrk7YxXztcZ67oM7Y8ypFA2HTlltmZtKkdhgzbNFFJnTdmqTP/EEjHbjppBr1Blpz7JckngUM2gkgjN25eNtRT2kPfj3Fe69yRINbzIpCG80JB5H6tL7LGtFzuRNuiYVNV6Zb1YHWCfG6YmavnrZVAeu24dlAOtJs8wVEuLSYTVxaRIPueZMRynEp0WdvQqOXKdMcYShj0kP6tJ9g46YxB1h7GLuzPneV5jVLmbjLr8dzj/nnnTqu88Y9UDwdSdZxp2TUU0XB1VdlTHtyj9Oapdrgw2IcCBLjF746o4sIn27K1udY5sCd6JsyHlPlE3J4eX++iqzT+izafVUJpONKdidZdVRyq+SCFdSytUvnPQlopl5F2F9LD6rD6/UM1JwVJ3xa9CusFR1GwYsYM6qn1n5fqdyP/4nci09saxx+9E4PL0kfSxrPSlOVn8BQ==</diagram></mxfile>
1 change: 1 addition & 0 deletions assets/drawio/575.distribute-candies.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile modified="2019-05-18T06:40:15.863Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" etag="YyJn435j3DqCnBhTC5-h" version="10.6.7" type="device"><diagram id="y-vvNxt2HP3UBzrcWMbX" name="第 1 页">7Zldc6IwFIZ/jZc4EL7spVrd7U4725le7MzeRQiQMRAWYtX++j2BpAraaTvrgrvai5K8CTnhPOckSAb2NN18KXCePPCQsAEyw83Avh0gdGON4L8UtrXgeE4txAUNa8naCU/0hSjRVOqKhqRsdBScM0HzphjwLCOBaGi4KPi62S3irGk1xzE5EJ4CzA7VHzQUSa2OkL/TvxIaJ9qy5d3ULSnWndWTlAkO+XpPsmcDe1pwLupSupkSJn2n/VLfN3+j9XViBcnER25Y3t0nLxm988to+/jwM/2efAsMy62HecZspZ5YzVZstQsKvspCIkcxB/ZknVBBnnIcyNY1MActESmDmgVFNRwpBNm8OVHr9fEhbAhPiSi20EXd4Iz8oZqWChpbVdc7AraeebLnfWQqESvq8evgO8dAQfnmM35yzs9P/tk56X0fQRLkskjTKu/2PSJ9QSHxxozGGWiC53vqPV4Q9shLKiiXrQsuBE+hA5MNExws48r/U854Udmyo+oPulTGxmVerw8SDtaViG4ksYmaz20ihFxYxtIRaB6EmTOksLREFMgWwwAsonmIBYaL1Eu4RgUhRiDNGkFS0FKkuDR0I4K4mU9xFm4NC42GeRafALylF0dF3jMPyLvmIXitnZw7ulzujGakM+yj88JuXy72mG3zpCvuqMXdMnsG/4G98J8Db74LfolTwgjPjCoCYGNfGnrHR/NqST49ebO5xVtuz+S9/5D8Oe7wLmqmvHv4btcpd//KvRPuHmomvNMz99GVezf57ja5j3pe52+u3Lvh7rRe7fpOeP3L8kr+b6/0TuvVzuyb/PXrTTfkfbOV86jnxd664O833ea83SLf92u9dcGfcLrNebu12ve+zx/7Je8xMDsJ6XMjArxfK3lENYl4JoyyOqADZ5vw+JvqHEO3QylW12qcMsfZnw3kTlzfHbhwq3kLlAq6WAkCFUmHklIbAgfUtpr2JXf5KFptxTXAFM1wBgt8SXQ4ZjyT4R5RxloSVuEeAHxSHMmDlIahNHP0DKh5SiR9oQ49ka7vJYQ/G3sz8zTHRXZr37Gtw30HOUeCEH0+CKG6O9is2vZOh+3Zbw==</diagram></mxfile>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/problems/263.ugly-number.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/problems/342.power-of-four-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/problems/342.power-of-four-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/problems/342.power-of-four.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/problems/575.distribute-candies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions problems/172.factorial-trailing-zeroes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

## 题目地址
https://leetcode.com/problems/factorial-trailing-zeroes/description/

## 题目描述

```
Given an integer n, return the number of trailing zeroes in n!.
Example 1:
Input: 3
Output: 0
Explanation: 3! = 6, no trailing zero.
Example 2:
Input: 5
Output: 1
Explanation: 5! = 120, one trailing zero.
Note: Your solution should be in logarithmic time complexity.
```

## 思路

我们需要求解这n个数字相乘的结果末尾有多少个0,由于题目要求log的复杂度,因此暴力求解是不行的。

通过观察,我们发现如果想要结果末尾是0,必须是分解质因数之后,2 和 5 相乘才行,同时因数分解之后发现5的个数远小于2,
因此我们只需要求解这n数字分解质因数之后一共有多少个5即可.

![172.factorial-trailing-zeroes-2](../assets/problems/172.factorial-trailing-zeroes-2.png)

如图如果n为30,那么结果应该是图中红色5的个数,即7。

![172.factorial-trailing-zeroes-1](../assets/problems/172.factorial-trailing-zeroes-1.png)

我们的结果并不是直接f(n) = n / 5, 比如n为30, 25中是有两个5的。
类似,n为150,会有7个这样的数字,通过观察我们发现规律`f(n) = n/5 + n/5^2 + n/5^3 + n/5^4 + n/5^5+..`

![172.factorial-trailing-zeroes-3](../assets/problems/172.factorial-trailing-zeroes-3.png)

如果可以发现上面的规律,用递归还是循环实现这个算式就看你的了。
## 关键点解析

- 数论


## 代码

```js


/*
* @lc app=leetcode id=172 lang=javascript
*
* [172] Factorial Trailing Zeroes
*/
/**
* @param {number} n
* @return {number}
*/
var trailingZeroes = function(n) {
// tag: 数论

// if (n === 0) return n;

// 递归: f(n) = n / 5 + f(n / 5)
// return Math.floor(n / 5) + trailingZeroes(Math.floor(n / 5));
let count = 0;
while (n >= 5) {
count += Math.floor(n / 5);
n = Math.floor(n / 5);
}
return count;
};
```
92 changes: 92 additions & 0 deletions problems/263.ugly-number.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
## 题目地址

https://leetcode.com/problems/ugly-number/description/

## 题目描述

```
Write a program to check whether a given number is an ugly number.
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.
Example 1:
Input: 6
Output: true
Explanation: 6 = 2 × 3
Example 2:
Input: 8
Output: true
Explanation: 8 = 2 × 2 × 2
Example 3:
Input: 14
Output: false
Explanation: 14 is not ugly since it includes another prime factor 7.
Note:
1 is typically treated as an ugly number.
Input is within the 32-bit signed integer range: [−231, 231 − 1].
```

## 思路

题目要求给定一个数字,判断是否为“丑陋数”(ugly number), 丑陋数是指只包含质因子2, 3, 5的正整数。

![263.ugly-number](../assets/problems/263.ugly-number.png)

根据定义,我们将给定数字除以2、3、5(顺序无所谓),直到无法整除。
如果得到1,说明是所有因子都是2或3或5,如果不是1,则不是丑陋数。

这就好像我们判断一个数字是否为n(n为大于1的正整数)的幂次方一样,我们只需要
不断除以n,直到无法整除,如果得到1,那么就是n的幂次方。 这道题的不同在于
它不再是某一个数字的幂次方,而是三个数字(2,3,5),不过解题思路还是一样的。

转化为代码可以是:

```js

while(num % 2 === 0) num = num / 2;
while(num % 3 === 0) num = num / 3;
while(num % 5 === 0) num = num / 5;

return num === 1;

```

> 我下方给出的代码是用了递归实现,只是给大家看下不同的写法而已。
## 关键点
- 数论
- 因数分解
## 代码

```js

/*
* @lc app=leetcode id=263 lang=javascript
*
* [263] Ugly Number
*/
/**
* @param {number} num
* @return {boolean}
*/
var isUgly = function(num) {
// TAG: 数论
if (num <= 0) return false;
if (num === 1) return true;

const list = [2, 3, 5];

if (list.includes(num)) return true;

for (let i of list) {
if (num % i === 0) return isUgly(Math.floor(num / i));
}
return false;
};
```

Loading

0 comments on commit 48bc053

Please sign in to comment.