Discussion About Subarrays Again

This is Discussion thread about Subarrays Again

what kind of optimization can be applied in the code as I am receiving the TLE error in my code having complexity O(n^2). Please help with the code below: