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 1 2 3 3 2 1 4 2 3 1 4 2 2 3 3 1 4 1 1 3 2 3 4. How many total oranges were in the basket at the end of the above sequence?
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 1 2 3 3 2 1 4 2 3 1 4 2 2 3 3 1 4 1 1 3 2 3 4. How many total oranges were in the basket at the end of the above sequence? Correct Answer 2
The logic follows here is:
Sequence of orders is given as 1 2 3 3 2 1 4 2 3 1 4 2 2 3 3 1 4 1 1 3 2 3 4.
put in one mango when ordered 'one',
put in one orange when ordered 'two',
put in one apple when ordered 'three' and is asked to take out from the basket one mango and orange when ordered 'four'.
Put in is represented by "+1" and taken out by "-1".
Drawing the table from the above information:
| Order Sequence | No of mango | No of orange | No of apple |
| 1 | +1 | ||
| 2 | +1 | ||
| 3 | +1 | ||
| 3 | +1 | ||
| 2 | +1 | ||
| 1 | +1 | ||
| 4 | -1 | -1 | |
| 2 | +1 | ||
| 3 | +1 | ||
| 1 | +1 | ||
| 4 | -1 | -1 | |
| 2 | +1 | ||
| 2 | +1 | ||
| 3 | +1 | ||
| 3 | +1 | ||
| 1 | +1 | ||
| 4 | -1 | -1 | |
| 1 | +1 | ||
| 1 | +1 | ||
| 3 | +1 | ||
| 2 | +1 | ||
| 3 | +1 | ||
| 4 | -1 | -1 |
Total orange at the end = +1 + 1 + 1 + 1 + 1 + 1 - 1 - 1 - 1 - 1 = 6 - 4 = 2
Hence, the correct answer is "2".