package leetcode;

/**
 * https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum/
 */
public class Problem795 {
    public int numSubarrayBoundedMax(int[] A, int L, int R) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem795 prob = new Problem795();
        System.out.println(prob.numSubarrayBoundedMax(new int[]{2, 1, 4, 3}, 2, 3)); // 3
    }
}

@@ -195,15 +195,264 @@
     
-// TODO
+int count = 0;%0A        int max = -1;%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            max = Math.max(max, A%5Bi%5D);%0A            if (L %3C= max && max %3C= R) %7B%0A                count++;%0A            %7D else %7B%0A                max = -1;%0A            %7D%0A        %7D
 %0A   
@@ -463,17 +463,21 @@
  return 
-0
+count
 ;%0A    %7D%0A
@@ -656,16 +656,196 @@
 ); // 3%0A
+        System.out.println(prob.numSubarrayBoundedMax(new int%5B%5D%7B1, 1, 1, 1%7D, 2, 3)); // 0%0A        System.out.println(prob.numSubarrayBoundedMax(new int%5B%5D%7B1, 1, 2, 1%7D, 2, 3)); // 6%0A
     %7D%0A%7D%0A

Update problem 795