BackmediumStrings Accenture Zomato

Potion Ingredient Sequencer Solution

Problem Statement

Given a string s and an integer length, find the number of unique subsequences of the given length that can be formed from the characters in s.

Example 1
Input
abcdefg
Output
1

Explanation: Step-by-step: with input 'abcdefg', we can form only one unique subsequence of length 7, which is 'abcdefg' itself, because all characters are unique and we cannot repeat them to form another subsequence of the same length.

Example 2
Input
aaaaaaa
Output
1

Explanation: Step-by-step: with input 'aaaaaaa', we can form only one unique subsequence of length 7, which is 'aaaaaaa' itself, because all characters are the same and we cannot form another subsequence of the same length with different characters.

Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free