beats 100% || very easy solution!
IntuitionThe intuition is to find the number of ways the array can be splitted such the left subarray is always maximum then the right subarray.Note: The array
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The intuition is to find the number of ways the array can be splitted such the left subarray is always maximum then the right subarray. 

**Note:** The array also consists of negative integers and should be split such that atleast one element should lies in the left and right!

# Approach
<!-- Describe your approach to solving the problem. -->
The approach is simple, we need to keep track of the count of the ways the array can be splitted so there is no need to actually include the array, just the count is enough. So we can keep track of the three variables here **adding** , which is used to add the upcoming elements, **tot**, helps to calculate the total sum of the array and finally **res**, used to return the total possible ways the array can be splitted.

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

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
![image.png](https://assets.leetcode.com/users/images/3a9dc83c-9d83-4827-a499-c7980417cf9f_1735874579.7667267.png)


# Code
```java []
class Solution {
    public int waysToSplitArray(int[] nums) {
        long adding=0;
        long tot=0;
        for(int i=0;i<nums.length;i++){
            tot+=nums[i];
        }
        int res=0;
        for(int i=0;i<nums.length-1;i++){
            adding+=nums[i];
            tot-=nums[i];
            if (adding>=tot){
                res++;
            }

        }
        return res;
    }
}
```
```python []
class Solution:
    def waysToSplitArray(self, nums: List[int]) -> int:
        adding=0
        tot=sum(nums)
        res=0
        for i in range(len(nums)-1):
            adding+=nums[i]
            tot-=nums[i]
            if adding>=tot:
                res+=1
        return res
```
```C++ []
class Solution {
public:
    int waysToSplitArray(vector<int>& nums) {
        long adding=0;
        long tot=0;
        for(int i=0;i<nums.size();i++){
            tot+=nums[i];
        }
        int res=0;
        for(int i=0;i<nums.size()-1;i++){
            adding+=nums[i];
            tot-=nums[i];
            if (adding>=tot){
                res++;
            }

        }
        return res;
    }
};
```
![image.png](https://assets.leetcode.com/users/images/88553bd7-e083-483f-a3fb-8352f292d676_1735874640.3406544.png)
# Happy Leetcoding~



['Java']