Can anyone help me with this problem.

My approach till now:

1.Make a prefix sum array from the input

2.In one single loop, find indices where `pref[i] = total_sum/3`

, such indices will be my possible indices for first block

3.For every such index(say idx), iterate over from `idx to n-1`

(say i) to again check

if `a[i]-a[idx] = total_sum/3`

, if yes then it is a possible index for the ending of 2nd block and count such possibilities.

But deservedly its showing tle and i’ not sure how to optimise it. code