question 1
The method runs on bbbaacc. How many characters has it written just after it reads the first c?
the answer, and why
the answer is C
Reading the first a ended bbb, so 3b. Reading the first c ended aa, so 2a. 3b2a is 4 characters; cc is written only at the end.
if you chose another
- That is 3b alone. Reading the first c also writes aa's run, 2a.
- That is the whole code, 3b2a2c. The last run is written only at the end.
- That counts the runs met so far, bbb, aa and c. Only runs that have ended are written.