add 54 in README

This commit is contained in:
ShusenTang 2019-01-17 00:04:30 +08:00
parent 81e719f104
commit 46cdd5b251
2 changed files with 2 additions and 1 deletions

View File

@ -44,6 +44,7 @@ LeetCode solutions with Chinese explanation. LeetCode中文题解。
| 49 |[Group Anagrams](https://leetcode.com/problems/group-anagrams/)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/49.%20Group%20Anagrams.md)|Medium| | | 49 |[Group Anagrams](https://leetcode.com/problems/group-anagrams/)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/49.%20Group%20Anagrams.md)|Medium| |
| 50 |[Pow(x, n)](https://leetcode.com/problems/powx-n/)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/50.%20Pow(x%2C%20n).md)|Medium| | | 50 |[Pow(x, n)](https://leetcode.com/problems/powx-n/)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/50.%20Pow(x%2C%20n).md)|Medium| |
| 53 |[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/53.%20Maximum%20Subarray.md)|Easy| | | 53 |[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/53.%20Maximum%20Subarray.md)|Easy| |
| 54 |[Spiral Matrix](https://leetcode.com/problems/spiral-matrix/)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/54.%20Spiral%20Matrix.md)|Medium| |
| 58 |[Length of Last Word](https://leetcode.com/problems/length-of-last-word)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/58.%20Length%20of%20Last%20Word.md)|Easy| | | 58 |[Length of Last Word](https://leetcode.com/problems/length-of-last-word)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/58.%20Length%20of%20Last%20Word.md)|Easy| |
| 66 |[Plus One](https://leetcode.com/problems/plus-one)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/66.%20Plus%20One.md)|Easy| | | 66 |[Plus One](https://leetcode.com/problems/plus-one)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/66.%20Plus%20One.md)|Easy| |
| 67 |[Add Binary](https://leetcode.com/problems/add-binary)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/67.%20Add%20Binary.md)|Easy| | | 67 |[Add Binary](https://leetcode.com/problems/add-binary)|[C++](https://github.com/ShusenTang/LeetCode/blob/master/solutions/67.%20Add%20Binary.md)|Easy| |

View File

@ -40,7 +40,7 @@
4. 竖直向上移动m-2次 4. 竖直向上移动m-2次
5. ...... 5. ......
直到移动次数变为0即遍历完成。所以该过程有两个周期一个是水平与竖直的周期周期为2另一个就是具体方向的周期周期为4。我们可以用一个大小为2的初始值为{n, m-1}的数组steps记录还剩下的两个方向的步数。为了方便四个方向的移动运算我们可以定义一个二维的const数组dirs其值为`{{0, 1}, {1, 0}, {0, -1}, {-1, 0}}`。 直到移动次数变为0即遍历完成。所以该过程有两个周期一个是水平与竖直的周期周期为2另一个就是具体方向的周期周期为4。我们可以用一个大小为2的初始值为[n, m-1]的数组steps记录还剩下的两个方向的步数。为了方便四个方向的移动运算我们可以定义一个二维的const数组dirs其值为`[[0, 1], [1, 0], [0, -1], [-1, 0]]`。
此方法可以很方便地推广到逆时针螺旋遍历只需要把方向右、下、左、上改成下、右、上、左即可即改动一下dirs的元素排列顺序即可。 此方法可以很方便地推广到逆时针螺旋遍历只需要把方向右、下、左、上改成下、右、上、左即可即改动一下dirs的元素排列顺序即可。