2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
id: 5900f37b1000cf542c50fe8e
|
2020-12-16 00:37:30 -07:00
|
|
|
|
title: 问题15:格子路径
|
2018-10-10 18:03:03 -04:00
|
|
|
|
challengeType: 5
|
|
|
|
|
|
videoUrl: ''
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --description--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
从2×2网格的左上角开始,只能向右和向下移动,右下角有6条路线。 
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
通过给定的`gridSize`有多少这样的路由?
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
`latticePaths(4)`应该返回70。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
|
assert.strictEqual(latticePaths(4), 70);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
`latticePaths(9)`应该返回48620。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
```js
|
|
|
|
|
|
assert.strictEqual(latticePaths(9), 48620);
|
|
|
|
|
|
```
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
`latticePaths(20)`应该返回137846528820。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
|
assert.strictEqual(latticePaths(20), 137846528820);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --solutions--
|
|
|
|
|
|
|