l**h 发帖数: 893 | 1 jump(int a[], int pos)
Given an array of numbers see if you can get to index with 0 in it from an
index by jumping through the array using the values in the array(you can
jump right or left). So if you have [1,2,1,0,3] you can get to 0, from 0 by
jumping 0; or you can get to 0 from 3, by jumping 3 index down to 2 and then
jumping 2 index up to 0.
怎么做,DP? | l**h 发帖数: 893 | 2 想到一个,可以把跳跃关系转换成有向图,一个节点最多可以到达两外两个(左和右),
就成了有向图中,找两点是不是有路径到达。
by
then
【在 l**h 的大作中提到】 : jump(int a[], int pos) : Given an array of numbers see if you can get to index with 0 in it from an : index by jumping through the array using the values in the array(you can : jump right or left). So if you have [1,2,1,0,3] you can get to 0, from 0 by : jumping 0; or you can get to 0 from 3, by jumping 3 index down to 2 and then : jumping 2 index up to 0. : 怎么做,DP?
| p*****2 发帖数: 21240 | 3
by
then
BFS就行了吧?
【在 l**h 的大作中提到】 : jump(int a[], int pos) : Given an array of numbers see if you can get to index with 0 in it from an : index by jumping through the array using the values in the array(you can : jump right or left). So if you have [1,2,1,0,3] you can get to 0, from 0 by : jumping 0; or you can get to 0 from 3, by jumping 3 index down to 2 and then : jumping 2 index up to 0. : 怎么做,DP?
| l**h 发帖数: 893 | 4 对,可以直接BFS, 第一次碰到值为零的路径就是了,不然就是到不了。
【在 p*****2 的大作中提到】 : : by : then : BFS就行了吧?
|
|