cpp implementation of Distinct Subsequences