question 1
The method runs on yybbbsss. How many characters has it written just after it reads the first s?
the answer, and why
the answer is A
Reading the first b ended yy, so 2y. Reading the first s ended bbb, so 3b. 2y3b is 4 characters; sss is written only at the end.
if you chose another
- That is 2y alone. Reading the first s also writes bbb's run, 3b.
- That is the whole code, 2y3b3s. The last run is written only at the end.
- That counts the runs met so far, yy, bbb and s. Only runs that have ended are written.