Distinct Subsequences Solution Write-up