DP Solution + Explanation
\nA = [2,1,4,3]\nL = 2 ; R = 3\n\nSubarrays which sum to range[L,R]\n\n[2] O, [2,1] O , [1,4] X, [4,3] X, [2,3] X, [2,4] X\n\nWe use permutation\n\n dp[ , , , ,
\nA = [2,1,4,3]\nL = 2 ; R = 3\n\nSubarrays which sum to range[L,R]\n\n[2] O, [2,1] O , [1,4] X, [4,3] X, [2,3] X, [2,4] X\n\nWe use permutation\n\n* dp[ , , , , , i,  ]\n* dp[i] : denotes max no of valid subarr ending with A[i]\n\n* Case 1: A[i] < L\nWe can only append A[i] with a valid subarr ending with A[i-1] hence cnt of valid is same   dp[i] = dp[i-1]\n* Case 2: A[i] > R\nAs the value itself greater than the limit hence not possibe with this element dp[i]=0\n\n* Case 3: In b/w\nAny subarr starts after the previous invalid\ndp[i] = dp[i] + i - prev\n\n\n```\n        res, dp = 0,0\n        prev = -1\n        for i in range(len(A)):\n            if A[i] < L and i > 0:\n                res += dp\n            elif A[i] > R: # Reset\n                dp = 0\n                prev = i\n            elif L <= A[i] <= R:\n                dp = i - prev\n                res += dp\n        return res
['Dynamic Programming', 'Python']