ZOMATO | iit bhu |

Zomato · Question · Posted Oct 2023

Given two vectors layers, energy of length n where layers denoting enerygy required to kill enemy at each index i (1<=i<=n) and energy denoting minimum energy should have after the fight. You have given an integer K which represents initial energy. Find the maximum number of enemy Alice can kill if he starts from each index. 1<=N<=10^5 Example: N=3 K=10 layers=[5, 8, 1] energy=[5,2,1] output: [1,2,1] explanation: starts from 1: k-5=5 >= 5 (energy should have 5 after fight). then go to index 2, 8>5 stop. same for index 2, ...

The full answer & interview discussion are available to premium members.

Log in Create a free account