Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Double Substring by Sim0000
"use strict";
function doubleSubstring(line) {
const n = line.length;
for(let m = n >> 1; m > 0; m--){
for(let i = 0; i <= n - m * 2; i++){
if(line.substring(i+m).includes(line.substring(i, i+m))) return m;
}
}
return 0;
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(doubleSubstring('aaaa'), 2, "First")
assert.equal(doubleSubstring('abc'), 0, "Second")
assert.equal(doubleSubstring('aghtfghkofgh'), 3, "Third")
console.log('"Run" is good. How is "Check"?');
}
Aug. 16, 2017
Comments: