🧩 Ways to Split Array (⏱ Runtime: 0ms, 🚀 Beats 100%)
✨ IntuitionWhen splitting an array, the goal is to count splits where the sum of the left part is greater than or equal to the sum of the right part. By leverag


### ✨ Intuition  
When splitting an array, the goal is to count splits where the sum of the left part is greater than or equal to the sum of the right part. By leveraging prefix sums, we can efficiently calculate the left and right segment sums during a single pass.

### 🔍 Approach  
1️⃣ Compute the total sum of the array (`sum`) to help calculate the right segment sum as (`rightsum = sum - leftsum`).

2️⃣ Traverse the array up to the second-to-last element, maintaining a running sum (`leftsum`) for the left segment.

3️⃣ For each split point, check if (`leftsum >= rightsum`). If true, increment the counter.

4️⃣ Return the counter after evaluating all split points.


### 📊 Complexity  
- **Time complexity:** \( O(n) \)  
  - The array is traversed twice: once to calculate the total sum and once to determine valid splits.  
- **Space complexity:** \( O(1) \)  
  - Only a few variables are used for computation, regardless of input size.  

### 💡 Runtime  
⏱ **0ms** – 🚀 Beats **100.00%** of submissions! 🎉
# Code
```cpp []
class Solution {
public:
    int waysToSplitArray(vector<int>& nums) {
        const int n = nums.size();
        long long sum = 0;
        long long cnt = 0;
        for (int i = 0; i < n; i++) {
            sum += nums[i];
        }
        long long leftsum = 0;
        long long rightsum = 0;
        for (int i = 0; i < n - 1; i++) {
            leftsum += nums[i];
            rightsum = sum - leftsum;
            if (leftsum >= rightsum) {
                cnt += 1;
            }
        }
        return cnt;
    }
};
```
['Array', 'Prefix Sum', 'C++']