# The fruits in basket problem

## The fruits in basket problem  You have a list of integers which are fruits.

Each int value is a fruit type

Each baskets can ONLY contain ONE type of fruit.

What is the max fruits you can collect?

You can only go left to right on the list.

e.g [strawberry, apple, mango, apple] -> answer is 3.

[pear, apple, orange, orange, apple, pear, apple, orange, mango, pear ] -> answer is 4

Solution:

```import java.util.HashMap;
import java.util.Iterator;
import java.util.Stack;

public class Solution {
HashMap<Integer, Integer> basket1 = new HashMap();
HashMap<Integer, Integer> basket2 = new HashMap();
Stack<HashMap> lastbucket = new Stack();
int maxFruits = 0;
public int totalFruit(int[] tree) {
for(int i=0;i<tree.length;i++){
int f = tree[i];
if(count==null){count=0;}
if(count==null){count=0;}
}else{
}
HashMap tmp = lastbucket.pop();
int ct=0;
ct = ct+1;
if(lastbucket.size()>0){
tmp = lastbucket.pop();
}else{
break;
}
}
}else{
HashMap tmp = lastbucket.pop();
int ct=0;
ct = ct+1;
if(lastbucket.size()>0){
tmp = lastbucket.pop();
}else{
break;
}
}
}
}

}
}

return maxFruits;
}