✅Detailed Explanation | 100% Beats | O(N) Solution | Java | C++ | Python
IntuitionTo split the array into two non-empty parts such that the left sum is greater than or equal to the right sum, we can efficiently calculate prefix and s
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
To split the array into two non-empty parts such that the left sum is greater than or equal to the right sum, we can efficiently calculate prefix and suffix sums while iterating through the array.

# Approach
<!-- Describe your approach to solving the problem. -->
1.  Compute Total Sum: Start with the total sum of the array as the initial "right" sum.
2.  Iterate Through the Array:
     - Maintain dummy as the left sum and fullSum as the right sum.
    - For each split, update dummy and fullSum by adding/removing the current element.
    - Check if dummy >= fullSum and increment the count if true.
3. Edge Case: Check the split after the first element separately before the loop starts.

# 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)$$ -->

# Code
```java []
class Solution {
    public int waysToSplitArray(int[] nums) {
        long fullSum = 0;
        for (int i = 1; i < nums.length; i++) {
            fullSum += nums[i];
        }

        int cnt = 0;
        long dummy = nums[0];
        if (dummy >= fullSum) {
            cnt = 1;
        }

        for (int i = 1; i < nums.length - 1; i++) {
            dummy += nums[i];
            fullSum -= nums[i];
            if (dummy >= fullSum) {
                cnt++;
            }
        }

        return cnt;
    }
}

```
```C++ []
class Solution {
public:
    int waysToSplitArray(vector<int>& nums) {
        long long fullSum = 0;
        for (int i = 1; i < nums.size(); i++) {
            fullSum += nums[i];
        }

        int cnt = 0;
        long long dummy = nums[0];
        
        if (dummy >= fullSum) {
            cnt = 1;
        }

        for (int i = 1; i < nums.size() - 1; i++) {
            dummy += nums[i];
            fullSum -= nums[i];
            if (dummy >= fullSum) {
                cnt++;
            }
        }

        return cnt;
    }
};
```
```python []
class Solution:
    def waysToSplitArray(self, nums):
        full_sum = sum(nums[1:])
        cnt = 0
        dummy = nums[0]
        
        if dummy >= full_sum:
            cnt = 1
        
        for i in range(1, len(nums) - 1):
            dummy += nums[i]
            full_sum -= nums[i]
            if dummy >= full_sum:
                cnt += 1
        
        return cnt
```


['Array', 'Prefix Sum', 'Python', 'C++', 'Java', 'Python3']