Java Solution|| Greedy Approach
ApproachGreedy approach- We need strictly greater energy and experience to defeat opponentCodeComplexity
Time complexity:O(N)

Space complexity:O(1)
# Approach
Greedy approach- We need strictly greater energy and experience to defeat opponent


# Code
```java []
class Solution {
    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {
        int total=0;
        int n=energy.length;
        for(int i=0;i<n;i++)
        {
            total+=energy[i];
        }

        int enTr=initialEnergy;
        int ans=0;
        if(total>=initialEnergy)
        {enTr=total-initialEnergy+1;
        ans=enTr;}

        for(int i=0;i<n;i++)
        {
            if(experience[i]>=initialExperience)
            {   ans+=experience[i]-initialExperience+1;
                initialExperience+=experience[i]-initialExperience+1;
            }
            
            enTr-=energy[i];
            initialExperience+=experience[i];

        }

        return ans;
    }
}
```


# Complexity
- Time complexity:O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
['Java']