java solution to Distinct Subsequences