Simple Prefix Sum Approach✅✅
IntuitionThe problem involves splitting the array into two non-empty parts such that the sum of the left part is greater than or equal to the sum of the right p
# Intuition
The problem involves splitting the array into two non-empty parts such that the sum of the left part is greater than or equal to the sum of the right part. To solve this, we need to efficiently calculate the prefix sum and compare the left and right sums for every possible split point.

# Approach
1. Compute the prefix sum array `pref`, where `pref[i]` represents the sum of the first `i + 1` elements.
2. The total sum of the array is stored in `pref[n-1]` (where `n` is the size of the array).
3. Iterate through the array up to the second-to-last element. For each split point `i`:
   - The sum of the left part is `pref[i]`.
   - The sum of the right part is `pref[n-1] - pref[i]`.
   - If the left sum is greater than or equal to the right sum, increment the counter `ans`.
4. Return the final count of valid split points stored in `ans`.

# Complexity
- Time complexity: $$O(n)$$  
  Constructing the prefix sum and iterating over the array both take linear time.
- Space complexity: $$O(n)$$  
  Space is used for the prefix sum array.

# Code
```cpp []
class Solution {
public:
    #define ll long long
    int waysToSplitArray(vector<int>& nums) {
        int n = nums.size();
        ll ans = 0;

        // Step 1: Calculate prefix sum
        vector<ll> pref(n, 0);
        pref[0] = nums[0];
        for (int i = 1; i < n; i++) {
            pref[i] = nums[i] + pref[i - 1];
        }

        // Step 2: Calculate total sum
        ll totalSum = pref[n - 1];

        // Step 3: Iterate through split points and check conditions
        for (int i = 0; i < n - 1; i++) {
            if (pref[i] >= (totalSum - pref[i])) {
                ans++;
            }
        }

        return ans;
    }
};
```
``` Java []
class Solution {
    public int waysToSplitArray(int[] nums) {
        int n = nums.length;
        long ans = 0;

        // Step 1: Calculate prefix sum
        long[] pref = new long[n];
        pref[0] = nums[0];
        for (int i = 1; i < n; i++) {
            pref[i] = nums[i] + pref[i - 1];
        }

        // Step 2: Calculate total sum
        long totalSum = pref[n - 1];

        // Step 3: Iterate through split points and check conditions
        for (int i = 0; i < n - 1; i++) {
            if (pref[i] >= (totalSum - pref[i])) {
                ans++;
            }
        }

        return (int) ans;
    }
}

```
```Python []
class Solution:
    def waysToSplitArray(self, nums: List[int]) -> int:
        n = len(nums)
        ans = 0

        # Step 1: Calculate prefix sum
        pref = [0] * n
        pref[0] = nums[0]
        for i in range(1, n):
            pref[i] = nums[i] + pref[i - 1]

        # Step 2: Calculate total sum
        total_sum = pref[-1]

        # Step 3: Iterate through split points and check conditions
        for i in range(n - 1):
            if pref[i] >= (total_sum - pref[i]):
                ans += 1

        return ans

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