NeetCode #234LC-904MediumSliding Window
← Back to All Problems

#234 · #904 · Fruit Into Baskets(水果成篮)

📌 Problem Statement & Constraints

You are given an array fruits where fruits[i] is the type of fruit on tree i. You have two baskets, each of which can hold only one type of fruit (but unlimited quantity). Starting from any tree, you must pick exactly one fruit from every tree while moving right, stopping when you cannot continue. Return the maximum number of fruits you can pick. Constraints: 1 <= fruits.length <= 10^5, 0 <= fruits[i] < fruits.length.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!