def min_jumps(nums):
    if not nums:
        return -1
    if len(nums) == 1:
        return 0
    jumps = end = farthest = 0
    for i in range(len(nums) - 1):
        farthest = max(farthest, i + nums[i])
        if i == end:
            if farthest == end:
                return -1
            jumps += 1
            end = farthest
            if end >= len(nums) - 1:
                return jumps
    return -1
