We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a915512 commit 64bf171Copy full SHA for 64bf171
2358-number-of-ways-to-split-array/2358-number-of-ways-to-split-array.cpp
@@ -0,0 +1,24 @@
1
+class Solution {
2
+public:
3
+ int waysToSplitArray(vector<int>& nums) {
4
+ long long right_sum=0;
5
+ long long left_sum=0;
6
+ int count_splits=0;
7
+
8
+ for(int i=1; i<nums.size(); i++)
9
+ {
10
+ right_sum += nums[i];
11
+ }
12
13
+ for(int j=0; j<nums.size()-1; j++)
14
15
+ left_sum += nums[j];
16
+ if(right_sum<=left_sum)
17
18
+ count_splits++;
19
20
+ right_sum-=nums[j+1];
21
22
+ return count_splits;
23
24
+};
0 commit comments