Explanation with Diagram 💨 | Prefix Sum | O(N) Approach | Beats 100% Users | Python
IntuitionThe task is to split the array into two parts such that the sum of the left subarray is greater than or equal to the sum of the right subarray. To achi
# Intuition
The task is to split the array into two parts such that the sum of the left subarray is greater than or equal to the sum of the right subarray. To achieve this efficiently, we can use a prefix sum approach to compute the cumulative sums of the array and compare the left and right sums for potential splits.

# Approach
### Compute Prefix Sums:

- Use a prefix array where ``prefix[i]`` represents the sum of the elements of the array from index 0 to `i`.
- This allows us to compute the left and right sums efficiently for any split.

### Iterate and Check Splits:

- For each index `i` from 0 to `n−2` (as the array must be split into two non-empty parts), calculate:
- Left Sum: `prefix[i]` (sum of the first i+1i+1 elements).
- Right Sum: `prefix[-1]` - `prefix[i]` (total sum of the array minus the left sum).
- Check if the left sum is greater than or equal to the right sum. If true, increment the count.

### Return the Count:
- The total number of valid splits is stored in count.

# Explanation:
![image.png](https://assets.leetcode.com/users/images/6819c353-dd6c-467a-8d33-426c4a550dbd_1735879417.5319052.png)


# Complexity
- Time complexity:
$$O(n)$$

- Space complexity:
$$O(n)$$
# Code
```python3 []
class Solution:
    def waysToSplitArray(self, nums: List[int]) -> int:
        #சூரியா அய்யா துணை | நிர்மல் ஸ்காரியா துணை 
        prefix = [0]*(len(nums))
        prefix[0] = nums[0]

        for i in range(1,len(nums)):
            prefix[i] = nums[i] + prefix[i-1]
        
        count = 0
        for i in range(len(nums)-1): # comparing with last element
            if prefix[i] >= prefix[-1] - prefix[i]:
                count += 1

        return count

        
```
['Array', 'Prefix Sum', 'Python3']