Skip to content
LC-2498 Medium LeetCode

2498. Frog Jump II

Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 62% Topics: Array, Binary Search, Greedy
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(1)

# greedy
class Solution(object):
    def maxJump(self, stones):
        """
        :type stones: List[int]
        :rtype: int
        """
        return stones[1]-stones[0] if len(stones) == 2 else max(stones[i+2]-stones[i] for i in xrange(len(stones)-2))

Solution from kamyu104/LeetCode-Solutions · MIT