PROBLEM OF THE DAY : 07/12/2023 | Number of subarrays with maximum values in giv...
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-07122023-number-of-subarrays-with-maximum-values-in-given-range/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Number of subarrays with maximum values in given range
Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Maths but also build up problem-solving skills.
In this problem, we are given, an array of N elements and L and R, and print the number of sub-arrays such that the value of the maximum array element in that subarray is at least L and at most R.
Example :
Input :
Arr = {2, 0, 11, 3, 0}
L = 1 and R = 10
Output :
4
Explanation:
The sub-arrays {2}, {2, 0}, {3} and {3, 0} have maximum in range 1-10.
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/number-of-subarrays-with-maximum-values-in-given-range5949/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/0b07c910-2a04-4d89-af1d-de5b860e3546
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK