UKG interview question

Count the Number of Good Subsequences