Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1011014 // maxRunlengthOfRepeatingChars

JavaX fragment (include)

static int maxRunlengthOfRepeatingChars(S s) {
  if (empty(s)) ret 0;
  int max = 0;
  for (int i = 0; i < l(s); ) {
    char c = s.charAt(i);
    int j = i+1;
    while (j < l(s) && s.charAt(j) == c) ++j;
    int n = j-i;
    max = max(max, j-i);
    i = j;
  }
  ret max;
}

Author comment

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: 388 / 407
Referenced in: [show references]