1
var findSubstringInWraproundString = function (p) {
2
const dp = Array(26).fill(0);
3
const origin = "a".charCodeAt(0);
4
let count = 0;
5

6
for (let index = 0; index < p.length; index++) {
7
const code = p.charCodeAt(index);
8
const preCode = p.charCodeAt(index - 1);
9
const pos = code - origin;
10

11
count = code - preCode === 1 || preCode - code === 25 ? count + 1 : 1;
12

13
dp[pos] = Math.max(count, dp[pos]);
14
}
15

16
return dp.reduce((total, count) => total + count);
17
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0