Defuse the Bombs
Another question about defusing bombs - uber-find-minimum-time-to-defuse-all-bombs
Janet is faced with the task of defusing N bombs, numbered from 1 to N. Each bomb i has a timer and will detonate in Yi seconds. To neutralize bomb i, Janet needs Xi seconds. He must finish defusing each bomb before or exactly when its timer runs out. Importantly, he can only work on one bomb at a time. Knowing this in advance, Janet has asked for your assistance. Your goal is to determine whether it's possible for him to defuse all the bombs in time. If it is, return the minimum total time required to complete the defusals. Otherwise, return -1.
Complete the function defuseBombs in the editor.
defuseBombs has the following parameter:
int[][] bombInfo: an array ofintarrays where each subarray contains two elements[Xi, Yi], representing the time taken by Janet to defuse theith bomb and the time by which theith bomb will explode
Returns
int: the minimum total time required to defuse all bombs if possible, otherwise -1
1Example 1
Constraints
Limits and guarantees your solution can rely on.
1 ≤ N ≤ 2 × 10^5