Sam and substrings Discussions | Algorithms | HackerRank
We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I think I found a easier way than dp:
long long int res = 0;
long long int f = 1;
for(int i = l-1; i >= 0; i--) {
res = (res + (s[i]-'0')*f*(i+1)) % MOD;
f = (f*10+1) % MOD;
}
Sam and substrings
You are viewing a single comment's thread. Return to all comments →