1 | static int maxRunlengthOfRepeatingChars(S s) { |
2 | if (empty(s)) ret 0; |
3 | int max = 0; |
4 | for (int i = 0; i < l(s); ) { |
5 | char c = s.charAt(i); |
6 | int j = i+1; |
7 | while (j < l(s) && s.charAt(j) == c) ++j; |
8 | int n = j-i; |
9 | max = max(max, j-i); |
10 | i = j; |
11 | } |
12 | ret max; |
13 | } |
Began life as a copy of #1001929
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011014 |
Snippet name: | maxRunlengthOfRepeatingChars |
Eternal ID of this version: | #1011014/1 |
Text MD5: | 15526990648ccba6d8a8cb4324a60dee |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-11 17:49:12 |
Source code size: | 287 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 445 / 472 |
Referenced in: | [show references] |