JavaScript | Easy to understand | With o(n) time
Intuition\nI believe the initial idea here is to iterate through the tasks and increment the energy and experience levels until they meet the requirements for e
# Intuition\nI believe the initial idea here is to iterate through the tasks and increment the energy and experience levels until they meet the requirements for each task. Then, deduct the required energy and add the gained experience.\n\n# Approach\nThe approach involves using two while loops for each task: one to handle energy requirements and the other for experience requirements. It increments the levels until they satisfy the current task, then deducts the energy and adds the experience. This process is repeated for each task in the given sequence.\n\n# Complexity\nTime complexity: O(n)\n \nwhere n is the number of tasks.\nThe function iterates through the tasks in a sequential manner.\n\n\nSpace complexity: O(1)\n\nsince the function uses a constant amount of space regardless of the input size.\n\n# Code\n```\n/**\n * @param {number} initialEnergy\n * @param {number} initialExperience\n * @param {number[]} energy\n * @param {number[]} experience\n * @return {number}\n */\nvar minNumberOfHours = function(initialEnergy, initialExperience, energy, experience) {\n    var hours = 0\n    for(let i =0;i<energy.length;i++){\n        \n        while(initialEnergy<=energy[i]){\n            initialEnergy++\n            hours++\n        }\n        while(initialExperience<=experience[i]){\n            initialExperience++\n            hours++\n        }\n        initialEnergy -= energy[i]\n        initialExperience += experience[i]\n    }\n    return hours\n};\n\n```
['JavaScript']