Here’s a random testcase your solution fails on:
1
10
gkd 1
gkd 1
gkd 1
j 1
gkd 1
j 0
j 0
gkd 1
j 0
aa 1
(the answer should be 9
).
Edit:
Or just check out this thread.
3 Likes
You are assuming that the same strings appear one after one. So it fails on test cases that do not follow this pattern as the one @ssjgz has shown. Or this one for example -
1
3
aa 1
bb 0
aa 0
(answer is 2 and yours will give 3)
1 Like