Math, asked by karan7632, 1 year ago

Given an array of integers and a number k, find the number of distinct integers in every contigious subsequence of size k

Answers

Answered by Anonymous
14

 \large\boxed{\underline{\mathcal{\red{A}\green{n}\pink{s}\orange{w}\blue{e}\red{r:}}}}

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}

Answered by Anonymous
17

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}

Similar questions