_Untrackable_'s blog

By _Untrackable_, history, 3 years ago, In English

Is there any way to tell the no of subsequences of a given string with all unique elements.. I had used recursion but gets TLE. anyone have any optimal answer?

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
3 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

use pnc

»
3 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

i am unable to reply back on codeforces currently

it says-"daily quota of 3 recepeints exceeded"

»
3 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Count the number of appearances of each character, let's store them in an array $$$c$$$, such that $$$c_1$$$ is the number of a's, $$$c_2$$$ is the number of b's, and so on. Now, for each character, we can either choose one of its appearances and add it into a subsequence, or not add the character at all. So we have $$$c_i+1$$$ possibilities for character $$$i$$$. Now we just multiply the number of possibilities for each character and we get the result.