题目:
题解:
def canCross(stones: List[int]) -> bool:
@lru_cache(None)
def dfs(pos,step):
if pos==stones[-1]: return True
for d in [-1,0,1]:
if step+d>0 and pos+step+d in set(stones):
if dfs(pos+step+d, step+d):
return True
return False
pos, step = 0, 0
return dfs(pos, step)