you visit farm single row fruit tree arrange left right the tree represent integer array fruit fruitsi type fruit ith tree producesyou want collect fruit possible however owner strict rule followyou basket basket hold single type fruit there limit fruit basket holdstarting tree choice pick exactly fruit tree include start tree move right the pick fruit fit basketsonce reach tree fruit fit basket stopGiven integer array fruit return maximum number fruit pick Example 1input fruit 121output 3explanation we pick 3 treesExample 2input fruit 0122output 3explanation we pick tree 122if start tree pick tree 01example 3input fruit 12322output 4explanation we pick tree 2322if start tree pick tree 12 Constraints1 fruitslength 1050 fruitsi fruitslength