Frage im Vorstellungsgespräch bei Bloomberg

How do you write an algorithm to count all subsets of strings in a string.

Antworten zu Vorstellungsgespräch

Anonym

8. Nov. 2015

int count(string &s) { return pow(2,s.size()); }

Anonym

9. März 2017

Both answers above are incorrect, as there can be repeats.

1

Anonym

14. Juli 2017

So, what's the answer if all previous answers were wrong?

Anonym

18. Juli 2017

sort the character array for the string then employ the algorithm to find all subsets without duplicates (backtracking algorithm) but don't actually store the result strings just count the number of them.