Java || Sliding Window + DP || 2ms || beats 100% || T.C - O(N) S.C - O(1)
\n    // O(A.length) O(1)\n\tpublic int numSubarrayBoundedMax(int[] A, int L, int R) {\n\n\t\tint len = A.length, sum = 0, count = 0, j = -1;\n\t\tfor (int i = 
\n    // O(A.length) O(1)\n\tpublic int numSubarrayBoundedMax(int[] A, int L, int R) {\n\n\t\tint len = A.length, sum = 0, count = 0, j = -1;\n\t\tfor (int i = 0; i < len; i++) {\n\n\t\t\tif (A[i] >= L && A[i] <= R) {\n\t\t\t\tcount = i - j;\n\t\t\t\tsum += count;\n\t\t\t} else if (A[i] < L) {\n\t\t\t\tsum += count;\n\t\t\t} else{\n\t\t\t\tj = i;\n                count = 0;\n            }\n\t\t}\n\n\t\treturn sum;\n\t}
[]