solve distinct subsequences