there special kind apple tree grow apple day n day on ith day tree grow applesi apple rot daysi days day daysi apple rotten eat on day apple tree grow apple denote applesi 0 daysi 0you decide eat apple day doctor away Note eat n daysgiven integer array day apple length n return maximum number apple eat Example 1input apple 12352 day 32142output 7explanation you eat 7 apple on day eat apple grow day on second day eat apple grow second day on day eat apple grow second day after day apple grow day rot on fourth seventh day eat apple grow fourth dayexample 2input apple 300002 day 300002output 5explanation you eat 5 apple on day eat apple grow day do fouth fifth day on sixth seventh day eat apple grow sixth day Constraintsn appleslength dayslength1 n 2 1040 applesi daysi 2 104daysi 0 applesi 0