Given an array of integers and a number k, find the number of distinct integers in every contigious subsequence of size k
Answers
Count unique subsequences of length K
Given an array of N numbers and an integer K. The task is to print the number of unique subsequences possible of length K.
Examples:
Input : a[ ] = {1, 2, 3, 4}, k = 3
Output : 4.
Unique Subsequences are:
{1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}
Input: a[ ] = {1, 1, 1, 2, 2, 2 }, k = 3
Output : 4
Unique Subsequences are
{1, 1, 1}, {1, 1, 2}, {1, 2, 2}, {2, 2, 2}
Answer:
Count unique subsequences of length K
Given an array of N numbers and an integer K. The task is to print the number of unique subsequences possible of length K.
Examples:
Input : a[ ] = {1, 2, 3, 4}, k = 3
Output : 4.
Unique Subsequences are:
{1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}
Input: a[ ] = {1, 1, 1, 2, 2, 2 }, k = 3
Output : 4
Unique Subsequences are
{1, 1, 1}, {1, 1, 2}, {1, 2, 2}, {2, 2, 2}