Your question is Longest Subarray After Removals. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
FactSet analytics surfaces may compact repeated values after filtering records. Given an integer array nums and an integer k, return the maximum length of a contiguous subarray consisting of the same integer after deleting at most k elements. The relative order of the remaining elements must be preserved.
You may choose any value and delete elements between its occurrences so that the retained occurrences become consecutive. Deleted elements do not contribute to the returned length.
Implement longest_equal_run(nums, k).
nums, a list of integers, and k, a non-negative integer.k deletions.def longest_equal_run(nums, k):