Company: Mathworks_31july
Difficulty: medium
Sum of All Values Problem Description Given a string num consisting of digits ('0' to '9'), find the sum of the values of all possible expressions formed by inserting '+' characters between digits. Rules: You can insert '+' characters between any two digits. No adjacent '+' characters are allowed. The expressions are evaluated as regular mathematical expressions. Since the answer can be large, return the value modulo (10 9 + 7). Complete the function getExpressionSums in the editor. It should return an integer representing the sum of all possible expression values modulo (10 9 + 7). The function accepts the following parameter: string num : the string of numbers Examples Example 1: Input: num = "123" Output: 168 Explanation: All possible valid expressions: "1+23" = 24 "12+3" = 15 "1+2+3" = 6 "123" = 123 Sum: 24 + 15 + 6 + 123 = 168 Answer: 168 modulo (10 9 + 7) = 168. Example 2: Input: num = "100" Output: 112 Explanation: All possible valid expressions are shown. "100", value = 100 "1