Beats 100% users in JAVA
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int waysToSplitArray(int[] nums) {
        int n = nums.length;
        
        // Calculate the total sum of the array
        long totalSum = 0;
        for (int num : nums) {
            totalSum += num;
        }
        
        // Initialize prefix sum and count of valid splits
        long prefixSum = 0;
        int validSplits = 0;
        
        // Iterate through the array to count valid splits
        for (int i = 0; i < n - 1; i++) {  // We split at position `i`
            prefixSum += nums[i];
            long suffixSum = totalSum - prefixSum;
            
            // If the prefix sum is greater than or equal to the suffix sum, it's a valid split
            if (prefixSum >= suffixSum) {
                validSplits++;
            }
        }
        
        return validSplits;
    }
}

```
['Java']