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 59078ab commit d927338Copy full SHA for d927338
2270. Number of Ways to Split Array
@@ -0,0 +1,14 @@
1
+class Solution {
2
+public:
3
+ int waysToSplitArray(vector<int>& nums)
4
+ {
5
+ vector<long> pref;
6
+ pref.push_back(0);
7
+ for(auto val : nums) pref.push_back(pref.back() + val);
8
+
9
+ int ans = 0, n = nums.size();
10
+ for(int i = 1; i < n; i++)
11
+ if(pref[i] >= pref.back() - pref[i]) ans++;
12
+ return ans;
13
+ }
14
+};
0 commit comments