公共子串计算
<h1>公共子串计算</h1>
<script type="text/javascript">
let [a, b] = ["asdfas", "werasdfaswer"]; // 6
let [alen, blen] = [a.length, b.length];
let res = 0;
for (let i = 0; i < alen; i++) {
for (let j = 0; j < blen; j++) {
let [x, y] = [i, j];
let count = 0;
while (x < alen && y < blen && a[x] === b[y]) {
x++;
y++;
count++;
}
if (res < count) {
res = count;
}
}
}
console.log(res);
</script>