solution for Distinct Subsequences