You are viewing a single comment's thread. Return to all comments →
js
const mod = BigInt(10 ** 9 + 7); const zero = BigInt(0); const one = BigInt(1); const ten = BigInt(10); function substrings(n) { const len = BigInt(n.length); let sum = zero; let f1 = one; let f2 = ten; for (let i = len - one; i >= zero; i--) { [sum, f1, f2] = [ (sum + BigInt(n[i]) * (i + one) * f1) % mod, (f1 + f2) % mod, (f2 * ten) % mod ]; } return sum; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sam and substrings
You are viewing a single comment's thread. Return to all comments →
js