1var findSubstringInWraproundString = function (p) {2const dp = Array(26).fill(0);3const origin = "a".charCodeAt(0);4let count = 0;56for (let index = 0; index < p.length; index++) {7const code = p.charCodeAt(index);8const preCode = p.charCodeAt(index - 1);9const pos = code - origin;1011count = code - preCode === 1 || preCode - code === 25 ? count + 1 : 1;1213dp[pos] = Math.max(count, dp[pos]);14}1516return dp.reduce((total, count) => total + count);17};