O(n) Solution using Prefix Sum with explaination! | 96.04% \ 87.64%
Intuition
The problem involves finding the number of ways to split an array such that the sum of the left part is greater than or equal to the sum of the right
# Intuition
- The problem involves finding the number of ways to split an array such that the sum of the left part is greater than or equal to the sum of the right part.
- Initially, it may seem like calculating the sums of both parts for every split is necessary, but this can be optimized by using cumulative sums.
---
# Approach
1. Compute the total sum of the array.
2. Initialize a variable `left_sum` to track the cumulative sum of elements on the left part of the split.
3. Iterate through the array (excluding the last element since we cannot split there).
   - Add the current element to `left_sum`.
   - Calculate the sum of the right part as `total - left_sum`.
   - Check if `left_sum >= right_sum`. If true, increment the counter `ways`.
4. Return the counter `ways` after completing the iteration.

#### This approach ensures that we calculate the sums efficiently without recomputing them repeatedly for each split.
---
# Complexity
- ### Time complexity: $$O(n)$$  
  - The algorithm iterates through the array once and performs constant-time operations in each iteration.

- ### Space complexity: $$O(1)$$  
  - Only a few variables are used for calculations, and no additional space is required proportional to the input size.

---

# Code
```python3 []
class Solution:
    def waysToSplitArray(self, nums: List[int]) -> int:
        ways = 0
        total = sum(nums)
        left_sum = 0
        for i in range(len(nums)-1):
            left_sum += nums[i]
            if left_sum >= (total - left_sum):
                ways += 1
        return ways
```
---
['Array', 'Prefix Sum', 'Python3']