Unique decimals in binary strings

Revision en1, by ankurrathinsit, 2021-07-10 16:02:00

So as the title says, given a binary string of length n (1<=n<=10^5) , find the number of unique decimals that can be obtained from subsequences of the binary string:

Example : 101

0=0

1=1

01 (same as 1) so rejected

10= 2

101= 5

11= 3

So, number of unique decimals are 5. I can only think of recursive solution. How to approach ?

Btw it was asked today in Google hiring contest.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English ankurrathinsit 2021-07-10 16:56:43 14 Tiny change: ' approach ?\n\nBtw ' -> ' approach this question ?\n\nBtw '
en2 English ankurrathinsit 2021-07-10 16:06:41 4 Tiny change: 'solution. How to app' -> 'solution. \n\nHow to app'
en1 English ankurrathinsit 2021-07-10 16:02:00 441 Initial revision (published)