Easy JavaScript Solution ❤️⭐
IntuitionSo Here We need to observe one things which is that , at every index we need to verify if sum of left side is** >=** sum of right side , that's why i w
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
So Here We need to observe one things which is that , at every index we need to verify if sum of left side is** >=** sum of right side , that's why i will always point to last index-1 (at max.) to satisfy given question constraint , Hence **Second **Condition**** can be easily achieved by just running a loop through i =0 to i< nums.length-1
Now we need to observe that at every index we need to determine sum of left elements >= sum of right elements ,  so for that we can use prefixSum array approach instead of brute force , we will create a prefixSum array which will store sum of elements till that particular index , such that 
prefix[i] = sum of elements till index i (inclusive) 

now we will run a loop again to nums array and at every index we will check if the sum of the elements till that index from prefixSum array is greater than sum of the elements from i+1 to nums.length-1 elements 
for that we can use this condition 

 if(prefixSum[i] >= (prefixSum[nums.length-1]- prefixSum[i])){
        noOfSplittingWays++;
    }

# Approach
<!-- Describe your approach to solving the problem. -->
To solve this problem, we need to determine if, at each index i (from 0 to n-2), the sum of elements on the left side (from the start to i) is greater than or equal to the sum of elements on the right side (from i+1 to the end).

**Key Observations:**
We can achieve this by iterating up to nums.length - 1 because there must be at least one element on the right side for a valid split.
Instead of recalculating sums for the left and right parts repeatedly (as in a brute force approach), we can use a prefix sum array:
prefix[i] will store the sum of elements from the start of the array up to index i.
Using this array, we can compute the sum of the left and right sides efficiently at each index.
**Prefix Sum Calculation:**
The prefix sum array helps us calculate the required sums in constant time:

**$$Left sum$$**: prefix[i]
**$$Right sum$$**: prefix[nums.length - 1] - prefix[i]



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

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

# Code
```javascript []
/**
 * @param {number[]} nums
 * @return {number}
 */
var waysToSplitArray = function(nums) {
    //Problem can be Solved USing Prefix Sum 

    // Nums = [10 , 4 , -8 , 7 ]
    let noOfways =0;
    let prefixSum = [];
       let temp=0;
    for(let i=0;i<nums.length;i++){
      temp+=nums[i];

      prefixSum[i] = temp;
    }

   //PrefixSum = [ 10, 14, 6, 13 ]

   for(let i=0;i<nums.length-1;i++){
    if(prefixSum[i] >= (prefixSum[nums.length-1]- prefixSum[i])){
        noOfways++;
    }
   }

   return noOfways;

};
```
['JavaScript']