question 1
The method runs on xxxddpp. How many characters has it written just after it reads the first p?
the answer, and why
the answer is B
Reading the first d ended xxx, so 3x. Reading the first p ended dd, so 2d. 3x2d is 4 characters; pp is written only at the end.
if you chose another
- That is 3x alone. Reading the first p also writes dd's run, 2d.
- That is the whole code, 3x2d2p. The last run is written only at the end.
- That counts the runs met so far, xxx, dd and p. Only runs that have ended are written.