Easy C++ solution || Beats 100%
IntuitionWhen splitting an array into two non-empty subarrays, the sum of elements in the left subarray and the right subarray determines whether the split is v
# Intuition
When splitting an array into two non-empty subarrays, the sum of elements in the left subarray and the right subarray determines whether the split is valid. A split is valid if the left subarray's sum is greater than or equal to the right subarray's sum. The challenge is to efficiently compute these sums for every possible split.


# Approach
1) Calculate Total Sum:

* Compute the total sum of the array elements once before processing splits.
* This allows us to calculate the sum of the right subarray dynamically by subtracting the left sum from the total sum.

2) Calculate Total Sum:

* Compute the total sum of the array elements once before processing splits.
* This allows us to calculate the sum of the right subarray dynamically by subtracting the left sum from the total sum.

3) Return the Count:

* After iterating through the array, return the count of valid splits.
# Complexity
- Time complexity:
O(n)

# Code
```cpp []
class Solution {
public:
    int waysToSplitArray(vector<int>& nums) {
        long long totalSum = 0;
        long long leftSum = 0; 
        int ans = 0;

        for (int num : nums) {
            totalSum += num;
        }

        for (int i = 0; i < nums.size() - 1; i++) {
            leftSum += nums[i]; 
            long long rightSum = totalSum - leftSum; 
            if (leftSum >= rightSum) {
                ans++; 
            }
        }

        return ans;
    }
};

```
['C++']