✅C++ | ✅Prefix Sum | ✅Easy O(N) solution
Please upvote if you find this solution helpful :)\n\nTC- O(N), SC- O(1)\n\nclass Solution {\npublic:\n    \n    //store total sum of nums in right_sum and iter
**Please upvote if you find this solution helpful :)**\n\n**TC- O(N), SC- O(1)**\n```\nclass Solution {\npublic:\n    \n    //store total sum of nums in right_sum and iterate over nums\n    //add nums[i] in left sum and subtract nums[i] from right sum\n    //when condition match increase valid_split by 1.\n    int waysToSplitArray(vector<int>& nums) \n    {\n        int valid_split=0;\n        long long right_sum=0, left_sum=0;\n        \n        //store total sum of nums in right_sum\n        for(int i=0; i<nums.size(); i++) right_sum += nums[i];\n        \n        for(int i=0; i<nums.size()-1; i++)\n        {\n            left_sum += nums[i]; //add nums[i] in left sum \n            right_sum -= nums[i]; // and subtract nums[i] from right sum\n            \n            //check whether left_sum is greater than or equal to right_sum\n            //and increase the valid_split by 1\n            if(left_sum >= right_sum) \n                valid_split++; \n        }\n        return valid_split;\n        \n    }\n};\n```
['C', 'Prefix Sum', 'C++']