GOOGLE Coding Question β Solved
1. Unique Decimal Count
Given a binary string consisting only of '0's and '1's, determine how many unique decimal values can be represented by all possible non-empty subsequences of the string.
Notes:
- The binary string may include leading zeros.
- A subsequence is formed by deleting some characters (possibly none) without changing the order of the remaining characters.
Example: "ace" is a subsequence of "abcde", but "aec" is not.
Example:
binary = "010"
- Distinct subsequences of the string are 0, 1, 01, 010, and 10.
- Their corresponding decimal representations are 0, 1, 1, 2, and 2.
- Distinct decimal numbers are 0, 1, and 2.
- The unique decimals count is 3.
Return 3.
Function Description: