C++ || EASY TO UNDERSTAND || Simple Prefix Sum Solution
\n#define ll long long int\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n        ll mod=1e9+7;\n        ll n=nums.size();\n        vecto
```\n#define ll long long int\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n        ll mod=1e9+7;\n        ll n=nums.size();\n        vector<ll> prefix(n,0);\n        prefix[0]=nums[0];\n        for(ll i=1;i<n;i++)\n        {\n            prefix[i]=prefix[i-1]+nums[i];\n        }\n        ll ans=0;\n        ll sum=0;\n        ll total=prefix[n-1];\n        for(int i=0;i<n-2;i++)\n        {\n            if(prefix[i]>total/3)\n            break;\n            ll j=lower_bound(prefix.begin()+i+1,prefix.end(),prefix[i]*2)-prefix.begin();\n            ll l=upper_bound(prefix.begin()+i+1,prefix.end(),(total-prefix[i])/2+prefix[i])-prefix.begin();\n            if(l<j)\n            continue;\n            else\n            {\n                if(l==n)\n                {\n                    ans=(ans%mod+(l-j-1)%mod)%mod;\n                }\n                else\n                {\n                    ans=(ans%mod+(l-j)%mod)%mod;\n                }\n            } \n        }\n        if(n==3&&ans>1)\n        return 1;\n        return (int)(ans%mod);\n    }\n};\n```\n**Please upvote to motivate me in my quest of documenting all leetcode solutions(to help the community). HAPPY CODING:)\nAny suggestions and improvements are always welcome**
[]