Company: Oracle_22may
Difficulty: medium
Cover Them All Problem Description Using the following rules, determine the minimum cost needed to reach any integer point on an infinite number line. If it is not possible to reach all points, return -1. The rules are: You start at position x = 0 For each available distance `distance[i]`, the cost to move to any point `x ± distance[i]` is `cost[i]` After paying the cost to use `distance[i]`, you can move to `x ± distance[i]` an infinite number of times at no additional cost Example: distance = [1, 2, 3], cost = [3, 1, 1] The minimum cost is 2, achieved by using `distance[1]=2` and `distance[2]=3`, costing `cost[1] + cost[2] = 1 + 1 = 2`. To move in the positive direction, you can repeat the pattern: right 3, left 2. This allows you to traverse positions `0 → 3 → 1 → 4 → 2 → 5 → 3 → 6 → 4 → ...` To move in the negative direction, you can reverse the pattern: left 3, right 2. This allows you to traverse positions `0 → -3 → -1 → -4 → -2 → -5 → ...` With these two movements, you can reach