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
bombInfo = [[2, 4], [1, 9], [1, 8], [4, 9], [3, 12]] return = 11
1 ≤ N ≤ 2 × 10^5
- Jump Game with Prime-3 StepsOA · Seen Jun 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026
- Convex Function MinimizationPHONE SCREEN · Seen May 2026
- Maximal Square AreaONSITE INTERVIEW · Seen May 2026
- First Unique IP Hitting the ServerPHONE SCREEN · Seen May 2026
public int defuseBombs(int[][] bombInfo) {
// write your code here
}