Find the frequency using prefix Array
for i in range ( len ( subarrays ) ) : NEW_LINE INDENT prefixArray [ subarrays [ i ] [ 0 ] - 1 ] += 1 NEW_LINE prefixArray [ subarrays [ i ] [ 1 ] ] -= 1 NEW_LINE DEDENT