How to solve this problem?
A supercomputer has several processors to deploy for execution. They are arranged sequentially in a row from 1 to n. The efficiency of each processor depends upon the order of deployment of its adjacent processors.
For the ith processor, the efficiency of the th processor is no_adjacent[i], one_adjacent[i], or both_adjacent[i] when neither, one, or both adjacent processors are deployed before processor i.
Note: The 1st and nth processors can only have one adjacent.
Find the maximum possible sum of efficiencies amongst all possible orders of deployment.
C++ is preferred
Language: C++20
Environment
```cpp
#include<bits/stdc++.h>
using namespace std;
/**
* The function is expected to return an INTEGER
* The function accepts following parameters:
* 1. INTEGER ARRAY skills
* 2. INTEGER K
*/
int findMaxLength(vector<int> skills, int k) {
}
int main() {
}
```
Unequal Elements
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[i] denotes the skill type of the ith 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[i] = x[i+1] for all 0 <= 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: skills = [11,2,3,21], k = 2
The longest possible subsequence is x = [11,2,2,1]. There are only two indices where x[1] = x[2] and x[3] = x[4]. Return its length, 5.
Function Description: Complete the function findMaxLength in the editor below. findMaxLength has the following parameters:
- int skills[n]: the different skill types
- int k: the maximum count of unequal adjacent elements
Returns: int the maximum value of m
Constraints: 1 <= n <= 10^3, 1 <= skills[i] <= 10