题目描述
Given a number as integer s, find the sum of all the elements present in all possible subsequences of s.
Example 1:
Input: S = "123"
Output: 24
Explanation: {1}, {2}, {3}, {1, 2}, {2, 3}
{1, 3}, {1, 2, 3} are all possible sub-
sequences
Example 2:
Input: S = "5"
Output: 5
Explanation: {5} is the only possible
sub sequence
User Task:
Your task is to complete the function subsequnceSum() which takes a single string as inputs and returns the sum. You need not take any input or print anything.
Expected Time Complexity: O(|s|)
Expected Auxiliary Space: O(1)
Constraints:
1 <= |S| <= 20
输入格式
见题面
输出格式
见题面
样例输入
S = "123"
样例输出
24