美文网首页
403. Frog Jump

403. Frog Jump

作者: matrxyz | 来源:发表于2018-01-16 13:25 被阅读0次

A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.
Given a list of stones' positions (in units) in sorted ascending order, determine if the frog is able to cross the river by landing on the last stone. Initially, the frog is on the first stone and assume the first jump must be 1 unit.
If the frog's last jump was k units, then its next jump must be either k - 1, k, or k + 1 units. Note that the frog can only jump in the forward direction.

Solution:DP

思路:

https://leetcode.com/problems/frog-jump/discuss/88824/Very-easy-to-understand-JAVA-solution-with-explanations

Time Complexity: O() Space Complexity: O()

Solution Code:


相关文章

  • 403. Frog Jump

    A frog is crossing a river. The river is divided into x u...

  • 8.21 - hard - 78

    403. Frog Jump首先做出来一个TLE的版本,因为这里面要search三种情况,可以用记忆化搜索来做。

  • Frog Jump

    题目A frog is crossing a river. The river is divided into x...

  • Frog Jump

    题目来源青蛙跳的题目,河中有一堆石头,问青蛙能不能跳过河。我一开始想着深度搜索遍历,代码如下: 没错…有超时了…然...

  • 发语音拼读下面单词

    ham bag leg nest list him lost frog jump must

  • [leetcode] Frog Jump

    题目地址A frog is crossing a river. The river is divided into...

  • Leetcode - Frog Jump

    My code: reference:https://discuss.leetcode.com/topic/599...

  • Recursion

    Fibonacci A frog can jump one or two steps at a time. How...

  • [刷题防痴呆] 0403 - 青蛙过河 (Frog Jump)

    题目地址 https://leetcode.com/problems/frog-jump/[https://lee...

  • [snap]frog jump 2D

    instant 2D版frog jump,规定跳跃方向是右或下方。 基本的思路就是依次动态规划,没有什么不同。只是...

网友评论

      本文标题:403. Frog Jump

      本文链接:https://www.haomeiwen.com/subject/ozjsoxtx.html