Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Long Repeat by Sim0000
"use strict";
function longRepeat(line) {
let last = '', max = 0, count = 0;
for(let c of line.split('')){
if(c == last){
count++;
} else {
if(count > max) max = count;
count = 1;
last = c;
}
}
if(count > max) max = count;
return max;
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(longRepeat('sdsffffse'), 4, "First")
assert.equal(longRepeat('ddvvrwwwrggg'), 3, "Second")
console.log('"Run" is good. How is "Check"?');
}
Aug. 18, 2017