Click here to see the full article post
That's a great solution! Is itertools.groupby(S) a function you think is worth knowing about? How else could I do it? Thanks @awice!
@slipperass I think line 6 should be
search: for (String word: words) .
@awice The solution code gives a compile error : " not a loop label: search "
@awice I think you need to update the test cases. I wrote a code but forgot to check for keys, and still, it got accepted. For example S = "heeellooo" and w = "axxxrrzzz" works.
I may misunderstand the description. My code failed in this test case:
My output is 1 but the answer is 3. I am a little confused. In my opinion, a word having only two 'd' like 'dd' or having having only one 'n' can not be counted. Because the length of a stretched group is at least 3. Obviously, there is only the first element "dinnssoo" that can be counted. Who can tell me that where the fault of my understanding is ? Many thanks.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.