You are viewing a single comment's thread. Return to all comments →
long substrings(string s) { long total = 0, endRight = 0, mod = 1000000007; for (int i=0; i < s.size(); i++) { int k = s[i] - '0'; endRight = (10*endRight + (i+1)*k) % mod; total = (total + endRight) % mod; } return total; }
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 →