You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array nums where nums[i] is the type of fruit the ith tree produces.
You want to collect as much fruit as possible. However, the owner has some strict rules:
Return the maximum number of fruits you can pick.
Example 1:
Input: nums = [1,2,1]
Output: 3
Explanation: We can pick from all 3 trees. The two types are {1, 2}.
Example 2:
Input: nums = [0,1,2,2]
Output: 3
Explanation: We can pick from trees [1,2,2] starting at index 1. The two types are {1, 2}.
Example 3:
Input: nums = [1,2,3,2,2]
Output: 4
Explanation: We can pick from trees [2,3,2,2] starting at index 1. The two types are {2, 3}.
1 <= nums.length <= 10^50 <= nums[i] < nums.length