Company: Visa_25oct
Difficulty: medium
Battery Management Simulation Problem Description Imagine that your mobile phone is currently out of battery, but you need to use it for t more minutes. Luckily, you have a number of spare batteries that are fully charged, where the i th battery lets you use the phone for capacity[i] more minutes. After capacity[i] , this battery becomes depleted, and has to be fully recharged for recharge[i] minutes before you can use it again. You use the extra batteries in the given order until each one is fully depleted, and then switch to the next one. If the next battery is still recharging, skip it and try the next one. This process continues cyclically until you are done using your phone after t minutes. Return the number of full batteries used during the t minutes you need to use your phone. If it is impossible to have the phone working during the entire duration of t minutes - i.e., if at some point all batteries are recharging and unavailable, return -1 . Note: You are not expected to provid