Put a stream of fruits into the fewest baskets such that no basket has more than one of the same fruit; return the baskets (a b c a b c d -> [[abc],[abc]]).
Asked in the onsite - coding I stage.
Implement fruit_baskets(fruits), where fruits is a list of fruit labels. Return a list of baskets, each represented as a list, containing every input fruit exactly once overall. Preserve stream order within each basket. The basket count must be minimal. If multiple valid arrangements exist, assign each fruit to the first existing basket that does not already contain it, creating a basket only when necessary.
def fruit_baskets(fruits):