Practice Find the Longest Equal Subarray
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Find the Longest Equal Subarray
Problem Statement
You are given a 0-indexed integer array nums and an integer k. A subarray is called equal if all of its elements are equal. Note that the empty subarray is an equal subarray. Return the length of the longest possible equal subarray after deleting at most k elements from nums. A subarray is a contiguous, possibly empty sequence of elements within an array.
Source: Find the Longest Equal Subarray on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [1,3,2,3,1,3], k = 3
3
# Example 2
nums = [1,1,2,2,1,1], k = 2
4
Constraints
Related LeetCode Problems
Practice more problems similar to Find the Longest Equal Subarray.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.