Question: Xavier needs to defuse N bombs from 1 to N . Every ith bomb is gonna explode in Y _ { 1 } seconds. He

Xavier needs to defuse N bombs from 1 to N.
Every ith bomb is gonna explode in Y_{1} seconds. He takes X_{i} seconds to defuse th bomb and he must defuse this bomb before or at this time to survive.He can only defuse one bomb at a time.
Xavier having this information beforehand has reached out to you for your help. Rescue Xavier to let him know if it is safe for him to defuse all the bombs. If he can, return minimum time by which all the bombs can be defused; if he cannot, return -1.
Example:
N: 5
bombinfo:
[[2,4]
[1,9]
[1,8]
[4,9]
[3,12]]
Give code for these constraints
[input] integer n
1<= N <=2*10^5
[input] array.array.integer bombinfo
bombinfo is a given 2D array of N Rows and 2 columns
X_i represents time taken by Xavier to defuse i
th bomb Y_i represents time by which ith bomb will explode
1<= X_{i}, Y_i <=10^9(1<= i<=N)
[output] integer64

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!