楼主:
sixB (6B)
2025-08-05 00:22:36904. 水果篮
2point刷过去
多退少补
很懒得记所以直接vector^^
class Solution {
public:
int totalFruit(vector<int>& fruits) {
int res = 0;
int n = fruits.size(), types = 0;
vector<int> cnt(n, 0);
for(int l = 0, r = 0, cur = 0; r < n; r++){
if(cnt[fruits[r]] == 0){
while(types >= 2){
cur