Minimum Hours of Training to Win a Competition Problem

Minimum Hours of Training to Win a Competition Problem — ExecCode Easy DSA Practice

Solve the Minimum Hours of Training to Win a Competition problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given the input needed to solve Minimum Hours of Training to Win a Competition. Your task is to compute the required answer and return the minimum number of training hours required to defeat all n opponents. You are entering a competition, and are given two positive integers initialEnergy and initialExperience denoting your initial energy and initial experience respectively. You are also given two 0-indexed integer arrays energy and experience, both of length n. You will face n opponents in order. The energy and experience of the i^th opponent is denoted by energy[i] and experience[i] respectively.

Examples

Input {"initialEnergy": 5, "initialExperience": 3, "energy": [1, 4, 3, 2], "experience": [2, 6, 3, 1]}; Output 8. Input {"initialEnergy": 2, "initialExperience": 4, "energy": [1], "experience": [3]}; Output 0

Constraints

n == energy.length == experience.length 1 <= n <= 100 1 <= initialEnergy, initialExperience, energy[i], experience[i] <= 100

Practice Minimum Hours of Training to Win a Competition free on ExecCode. Browse DSA problems, topic map, and placement guides.