MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / Solution

Class Solution

NumberOfWaysToSplitArray.java:2–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1
2class Solution {
3 public int waysToSplitArray(int[] nums) {
4 long right = 0;
5 long left = 0;
6 for(int num : nums){
7 right += num;
8 }
9 int n = nums.length;
10 int count=0;
11 for(int i=0;i<n-1;i++){
12 left += nums[i];
13 right -= nums[i];
14 if(left >= right){
15 count++;
16 }
17 }
18 return count;
19 }
20}
21
22//only left sum
23class Solution {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected