Sum of all substrings of a number
Easy Accuracy: 37.47% Submissions: 6280 Points: 2

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.

Example 1:

Input:
S = 1234
Output: 1670
Explanation: Sum = 1 + 2 + 3 + 4 + 12 +
23 + 34 + 123 + 234 + 1234 = 1670


Example 2:

Input:
S = 421
Output: 491
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).

Constraints:
1 <= |S| <= 104

We are replacing the old Disqus forum with the new Discussions section given below.