You are given an integer array elements. You may select any subsequence (i.e., delete zero or more elements without changing the order of the remaining elements).
Return the maximum possible length of a subsequence such that there are at most k adjacent pairs with different values. In other words, for a subsequence [x₀, x₁, …, xₘ₋₁], the number of indices i with 0 ≤ i < m - 1 and xᵢ ≠ xᵢ₊₁ must be at most k.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected