nikomarow
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
function isPeriodic(str) {
f: for (let i = 0; i <= str.length / 2; i += 1) {
window.P = str.substring(0, i);
if (!window.P) {
continue;
}
for (let x = 0; x < str.length; x += window.P.length) {
const currentPattern = str.substr(x, window.P.length);
if (currentPattern !== window.P) {
break;
} else if (x + window.P.length === str.length) {
console.log('RESULT', window.P, str.length / window.P.length);
break f;
}
}
}
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- nikomarow January 23, 2020