A boy is asked to put in a basket one mango when ordered 'One', one orange when ordered 'Two', one apple when ordered 'Three' and is asked to take out from the basket one mango and orange when ordered 'Four'. A sequence of orders is given as 12332142314223314113234 . How many total fruits will be in the basket at the end of above order sequence?
Step-by-step Solution:
Orders:
Sequence: 12332142314223314113234
Let’s track the counts for (Mangoes, Oranges, Apples) through the sequence:
Start: (M=0, O=0, A=0)
1 → +M → (1,0,0)
2 → +O → (1,1,0)
3 → +A → (1,1,1)
3 → +A → (1,1,2)
2 → +O → (1,2,2)
1 → +M → (2,2,2)
4 → -(M,O) → (1,1,2)
2 → +O → (1,2,2)
3 → +A → (1,2,3)
1 → +M → (2,2,3)
4 → -(M,O) → (1,1,3)
2 → +O → (1,2,3)
2 → +O → (1,3,3)
3 → +A → (1,3,4)
3 → +A → (1,3,5)
1 → +M → (2,3,5)
4 → -(M,O) → (1,2,5)
1 → +M → (2,2,5)
1 → +M → (3,2,5)
3 → +A → (3,2,6)
2 → +O → (3,3,6)
3 → +A → (3,3,7)
4 → -(M,O) → (2,2,7)
At the end of the sequence, the basket contains:
Total Fruits = 2 + 2 + 7 = 11
Final Answer: 11