cpp implemenataion of Distinct Subsequences