由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 一道变形的Jump题
相关主题
Leetcode 上的jump game有人做出来了吗?问个leetcode上的题目jump gameII,最优解是dijkstra最短路径
问一个编程题检查graph里面是否有circle,是用BFS,还是DFS?
问两道leetcode上的jump game 题GM面经
攒人品,分享Pinterest面经贴点面试题, ms和google的
leetcode jump game2CLRS算法书中BFS的疑问
问一道题三道 Amazon Onsite Coding 题 (转载)
问一个我onsite的题请教一道G家onsite题。。。
Amazon的题今天1/9 Amazon onsite,当天晚上收到offer,上面筋
相关话题的讨论汇总
话题: jumping话题: index话题: jump话题: array话题: get
进入JobHunting版参与讨论
1 (共1页)
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就行了吧?

1 (共1页)
进入JobHunting版参与讨论
相关主题
今天1/9 Amazon onsite,当天晚上收到offer,上面筋leetcode jump game2
问一道Uber的电面题问一道题
报点面经问一个我onsite的题
贡献一道G家onsite题吧Amazon的题
Leetcode 上的jump game有人做出来了吗?问个leetcode上的题目jump gameII,最优解是dijkstra最短路径
问一个编程题检查graph里面是否有circle,是用BFS,还是DFS?
问两道leetcode上的jump game 题GM面经
攒人品,分享Pinterest面经贴点面试题, ms和google的
相关话题的讨论汇总
话题: jumping话题: index话题: jump话题: array话题: get