Please enter your email address or userHandle.
Given an integer S represented as a string, the task is to get the sum of all possible sub-strings of this string.
As the answer will be large, print it modulo 10^9+7.
S = 1234
Explanation: Sum = 1 + 2 + 3 + 4 + 12 +
23 + 34 + 123 + 234 + 1234 = 1670
S = 421
Explanation: Sum = 4 + 2 + 1 + 42 + 21
You only need to complete the function sumSubstrings that takes S as an argument and returns the answer modulo 1000000007.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
1 <= |S| <= 104
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
want to view the editorial?
Login to access your submissions.