Description
Solutions
Sum of All Values
🔥 FULLTIME📚RELATED PROBLEMS
A school in HackerLand organized a scholarship exam with this interesting mathematics problem on addition.
Given a string num
that consists of digits ('0' to '9'), a '+' can be inserted between its characters. No adjacent '+' characters are allowed. The value of the expression is then evaluated. Find the sum of the values of all possible expressions after inserting '+' characters any number of times (possibly zero). Since the answer can be large, return the value modulo (10^9 + 7).
Function Description
Complete the function getExpressionSums
in the editor below.
getExpressionSums
has the following parameter(s):
Example 1:
Input: num = "123"
Output: 168
Explanation:All possible valid expressions are shown.Their sum is 24 + 15 + 6 + 123 = 168. Thus, the answer is 168 modulo (10^9 + 7) which is 168.
- "1 + 23", value = 24
- "12 + 3", value = 15
- "1 + 2 + 3", value = 6
- "123", value = 123
Constraints:
An unknown myth for now 🥲

Related Problems
Testcase
Result
Case 1
input:
output: