=======================================================
Explanation:
R = red apple
G = green apple
The best case scenario is when Leyan picks 3 red apples in a row (or 3 green apples in a row). So either RRR or GGG. However, she might not be so lucky.
We have to consider the opposite side of the spectrum and consider the worst case scenario.
Consider the case of alternating colors. If she selects four apples and the colors alternate, then she might have something like RGRG. There are two of each color so far.
Whatever she picks next will mean she has 3 of the same color. So it could be RGRGR or RGRGG. Therefore, she must select 5 apples to guarantee she has at least 3 of the same color.
--------------------
Extra info (optional section)
If you are curious about how many apples are needed to guarantee she has 3 of both colors, then she would have to select 13 apples.
Why? Let's say she has really bad luck and selects 10 red apples in a row. The 3 extra selections are guaranteed to be green.