GLEAN Hiring Online Assessment Question | maximum sub array
Question · Posted Jun 2026
Problem Statement You are given an integer array nums and a positive integer k. A subarray is considered valid if the maximum element of the entire array appears at least k times within that subarray. Return the total number of such valid subarrays. Example 1 Input nums = [1,3,2,3,3] k = 2 Output 6 Explanation The maximum element in the array is 3. Valid subarrays where 3 appears at least 2 times: [1,3,2,3] [1,3,2,3,3] [3,2,3] [3,2,3,3] [2,3,3] [3,3] Total = ...
The full answer & interview discussion are available to premium members.
Log in Create a free account