🔥Space optimized Solution for Beginners! Beats 100%!🔥
ApproachComplexity
Time complexity:O(N)

Space complexity:O(1)
Code
# Approach
<!-- Describe your approach to solving the problem. -->
![image.png](https://assets.leetcode.com/users/images/253c2fac-39da-408b-864e-d79593ee1f07_1735889751.0086935.png)


# Complexity
- Time complexity:O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
![image.png](https://assets.leetcode.com/users/images/cf542671-3739-457d-b873-8be58fd6e2b3_1735889862.7129176.png)



# Code
```cpp []
class Solution {
public:
    using ll=long long int;
    int waysToSplitArray(vector<int>& nums) {
        int n=nums.size();
        ll totalSum=accumulate(nums.begin(),nums.end(),0LL);
        ll leftSum=0;
        int validSplits=0;

        for(int i=0;i<n-1;i++){
            leftSum+=nums[i];
            //ll rightSum=totalSum-leftSum;
            if(2*leftSum>=totalSum)validSplits++;
        }
        return validSplits;
    }
};
```
['C++']