✅✅ easy prefix sum approch 🔥🔥 || o(n) Space Complexity || o(n) Time Complexity
IntuitionThe problem requires dividing the array into two non-overlapping parts such that the sum of the left part is greater than or equal to the sum of the ri
Intuition

The problem requires dividing the array into two non-overlapping parts such that the sum of the left part is greater than or equal to the sum of the right part.
To efficiently solve this, we use prefix sums to compute the total sum of any part of the array in constant time.
Approach
Calculate Prefix Sums from Front:

Create a prefixfront array where each element at index i contains the sum of elements from the beginning of the array up to index i.
Calculate Prefix Sums from Back:

Create a prefixback array where each element at index i contains the sum of elements from index i to the end of the array.
Iterate and Compare:

For each index i (up to n - 2), check if the sum of the left part (prefixfront[i]) is greater than or equal to the sum of the right part (prefixback[i + 1]).
If the condition is satisfied, increment the count.
Return the Result:

Return the total count of valid splits.

Complexity
Time Complexity:
Calculating prefix sums takes O(n).Iterating through the array to count valid splits also takes O(n).Overall time complexity: O(n).

Space Complexity:
Space used for prefixfront and prefixback arrays: O(n).
Overall space complexity: O(n).

# Code
```cpp []
class Solution {
public:
    int waysToSplitArray(vector<int>& nums) {

        int n=nums.size();

        vector<long long>prefixfront(n);
        vector<long long>prefixback(n);

        for(int i=0;i<n;i++)
        {
            if(i==0)
            {
                prefixfront[i]=nums[i];
            }
            else
            {
                prefixfront[i]=prefixfront[i-1]+nums[i];
            }
        }


        for(int i=n-1;i>=0;i--)
        {
            if(i==n-1)
            {
                prefixback[i]=nums[i];
            }
            else
            {
                prefixback[i]=prefixback[i+1]+nums[i];
            }
        }

        int count=0;

        for(int i=0;i<n-1;i++)
        {
                if(prefixfront[i]>=prefixback[i+1])
                {
                    count++;
                }
        }

    return count;


    }
};
```
['Prefix Sum', 'C++']