1h 25 m
left
hackerrank.com/test/6qpsoib3qq1/questions/at91gh7n34s
Gmail
routube
Maps
Transtate
A B Booknita
3. Question 3
A test needs to be prepared on the HackerRank platform with questions from different sets of skills to assess candidates. Given an array, skills, of size \( n \), where skills ilj denotes the skill type of the \( f^{t h} \) question. select skills for the questions on the test. The skills should be grouped together as much as possible. The goal is to find the maximum length of a subsequence of skills such that there are no more than \( k \) unequal adjacent elements in the subsequence. Formally, find a subsequence of skills, call it \( x \), of length \( m \) such that there are at most \( k \) indices where \( x[j] l=x[i+1] \) for all \( 0 \leq i<m \).
Note: A subsequence of an array is obtained by deleting several elements of the array (possibly zero or all) without changing the order of the remaining elements. For example, [1, 3, 4], [3] are subsequences of [1, 2, 3, 4) whereas [1, 5], [4, 3] are not.
Example
\[
\text { skills }=[1,1,2,3,2,1], k=2 .
\]
The longest possible subsequence is \( x=[1,1,2,2,1] \). There are only two indices where \( x[1]!=x[2] \) and \( x[3] \) \( f=x[4] \).
Return its length, 5 .
Function Description
Complete the function findMaxLength in the editor below.
findMaxLength has the following parameter(s):
int skills[n]: the different skill types
int \( k \) : the maximum count of unequal adjacent elements
Language
\( \mathrm{C}+20 \)
- E Enwironthent
```
>)#include cbits/stdc+*.ho
I
- Complete the 'findraxLength' function bricur
- The function is expected to return an Lertegear-
- The function accepts following paraneters:
- 1. INTEGER_ARRAY skitlls
* 2. intEgER k
|
int findMaxLength(vector<ints skills, int k) {
\
> int main()|
```