Tap here to switch tabs
Problem
Submissions

Problem: Frog Jump II

med
30 min
Try to solve the Frog Jump II problem.

Statement

You are given a 00 indexed integer array stones sorted in strictly increasing order, representing the positions of stones in a river.

A frog starts at the first stone, travels to the last stone, and then returns to the first stone. The frog can visit each intermediate stone at most once across the entire round trip.

The length of a jump between stones[i] and stones[j] is equal to ∣|stones[i] −- stones[j]∣|. The cost of a path is defined as the maximum jump length taken during the journey.

Return the minimum possible cost of a valid round trip path.

Constraints:

  • 2≤2 \leq stones.length ≤105\leq 10^5

  • 0≤0 \leq stones[i] ≤109\leq 10^9

  • stones[0] =0= 0

  • stones is sorted in a strictly increasing order.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Frog Jump II

med
30 min
Try to solve the Frog Jump II problem.

Statement

You are given a 00 indexed integer array stones sorted in strictly increasing order, representing the positions of stones in a river.

A frog starts at the first stone, travels to the last stone, and then returns to the first stone. The frog can visit each intermediate stone at most once across the entire round trip.

The length of a jump between stones[i] and stones[j] is equal to ∣|stones[i] −- stones[j]∣|. The cost of a path is defined as the maximum jump length taken during the journey.

Return the minimum possible cost of a valid round trip path.

Constraints:

  • 2≤2 \leq stones.length ≤105\leq 10^5

  • 0≤0 \leq stones[i] ≤109\leq 10^9

  • stones[0] =0= 0

  • stones is sorted in a strictly increasing order.