question 1
The method runs on zzzxxcc. How many characters has it written just after it reads the first c?
the answer, and why
the answer is A
Reading the first x ended zzz, so 3z. Reading the first c ended xx, so 2x. 3z2x is 4 characters; cc is written only at the end.
if you chose another
- That is 3z alone. Reading the first c also writes xx's run, 2x.
- That is the whole code, 3z2x2c. The last run is written only at the end.
- That counts the runs met so far, zzz, xx and c. Only runs that have ended are written.