Back to problems

Max Levels from Each Index

Algorithm · Uber · Medium

You have a linear sequence of n levels, indexed from 0 to n - 1. Two integer arrays layers and energy of length n are provided, along with an integer K that represents your starting stamina. For any chosen starting level i, you attempt levels i, i + 1, i + 2, … in order. At each level j, you first subtract layers[j] from your current stamina; if the stamina remaining afterwards is greater than or equal to energy[j], you clear the level and immediately proceed to the next…

Checking your access…