LENSKART SDE OA (2024) | Sliding Window Counting and Range-Based Subarray Analysis Problem| Java Solution
Question · Posted Jun 2026
Q1. Count Subarrays with Maximum Element Within a Given Range Problem Statement You are given an integer array nums and two integers: left right Return the number of contiguous subarrays whose maximum element lies within the inclusive range: [left, right] Example 1 Input nums = [2,1,4,3] left = 2 right = 3 Output 3 Explanation Valid subarrays are: [2] [2,1] [3] Total: 3 Example 2 Input nums = [2,9,2,5,6] left = 2 right = 8 Output 7 Constraints 1 <= ...
The full answer & interview discussion are available to premium members.
Log in Create a free account