Security Breaching

Company: uber_14oct

Difficulty: medium

Problem Statement

Security Breaching Problem Description A cyber attack simulation has n security levels, numbered 0 to n - 1 in the order the attacker meets them. The attacker may begin at any level i , always with the same initial energy k , and then moves forward one level at a time. At each level j it reaches: The attacker must spend layers[j] energy to breach the level. If the energy it currently holds is less than layers[j] , the attack fails and ends immediately; no later level is visited. Otherwise the energy held drops by layers[j] . If the energy remaining after the breach is at least energy[j] , the attacker scores 1 point. The attacker then moves on to level j + 1 . Breaching the last level also ends the attack. For every starting level i , compute the number of points an attack that starts at level i with energy k scores. Each starting level is a separate attack that begins with the full k energy. Function Description Complete the function getNumPoints in the editor. It has the following pa