Tap here to switch tabs
Problem
Submissions

Problem: Jump Game VIII

Try to solve the Jump Game VIII problem.

Statement

You are given two integer arrays nums and costs, both of length n, indexed from 00 to n−1n - 1.

You begin at index 00 and wish to reach index n−1n - 1. From a given index i, you are permitted to jump to another index j such that i << j if and only if at least one of the following conditions is satisfied:

  • nums[i] ≤\leq nums[j] and nums[k] << nums[i] for every index k where i << k << j.

  • nums[i] >> nums[j] and nums[k] ≥\geq nums[i] for every index k where i << k << j.

The cost incurred by jumping from index i to index j is equal to costs[j].

Return the minimum total cost required to reach index n−1n - 1 starting from index 00.

Constraints:

  • n ==== nums.length ==== costs.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq nums[i], costs[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Jump Game VIII

Try to solve the Jump Game VIII problem.

Statement

You are given two integer arrays nums and costs, both of length n, indexed from 00 to n−1n - 1.

You begin at index 00 and wish to reach index n−1n - 1. From a given index i, you are permitted to jump to another index j such that i << j if and only if at least one of the following conditions is satisfied:

  • nums[i] ≤\leq nums[j] and nums[k] << nums[i] for every index k where i << k << j.

  • nums[i] >> nums[j] and nums[k] ≥\geq nums[i] for every index k where i << k << j.

The cost incurred by jumping from index i to index j is equal to costs[j].

Return the minimum total cost required to reach index n−1n - 1 starting from index 00.

Constraints:

  • n ==== nums.length ==== costs.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq nums[i], costs[i] ≤105\leq 10^5