Back to problems

Subarray with Most Target Element

Algorithm · Roblox · Medium

Problem Statement You are given an integer array nums, an index targetIndex (0‑based), and a window length windowSize. The target value is defined as nums[targetIndex]. Your task is to return the starting index of a contiguous subarray of length windowSize that contains the maximum number of occurrences of the target value. If several such subarrays achieve the same maximum count, return the smallest starting index among them. Implement a function with the following…

Checking your access…