【Leetcode】904. Fruit Into Baskets

1 用sliding window来做:sliding window就是维护一个window,最后得到这个window的长度

2 用collections.Counter来计数,每遍历一下,里面计数加1

3 但当counter里面的个数大于2的时候,需要删除最左边的;当这个数的计数为0时,就删除这个计数


你可能感兴趣的:(【Leetcode】904. Fruit Into Baskets)