Tap here to switch tabs
Problem
Submissions

Problem: Find the Maximum Length of a Good Subsequence I

med
30 min
Try to solve the Find the Maximum Length of a Good Subsequence I problem.

Statement

You are given an integer array nums and a non negative integer k.

A sequence of integers seq is defined as good if there are at most k indices i within the range 0≤i≤0 \le i \le seq.length −2- 2 such that seq[i] ≠\neq seq[i + 1].

Return the maximum possible length of a good subsequence of nums.

Constraints:

  • 1≤1 \le nums.length ≤500\le 500

  • 1≤1 \le nums[i] ≤109\le 10^9

  • 0≤0 \le k ≤min⁡(\le \min(nums.length, 25)25)

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Maximum Length of a Good Subsequence I

med
30 min
Try to solve the Find the Maximum Length of a Good Subsequence I problem.

Statement

You are given an integer array nums and a non negative integer k.

A sequence of integers seq is defined as good if there are at most k indices i within the range 0≤i≤0 \le i \le seq.length −2- 2 such that seq[i] ≠\neq seq[i + 1].

Return the maximum possible length of a good subsequence of nums.

Constraints:

  • 1≤1 \le nums.length ≤500\le 500

  • 1≤1 \le nums[i] ≤109\le 10^9

  • 0≤0 \le k ≤min⁡(\le \min(nums.length, 25)25)