Class Solution
java.lang.Object
g1701_1800.s1712_ways_to_split_array_into_three_subarrays.Solution
1712 - Ways to Split Array Into Three Subarrays.<p>Medium</p>
<p>A split of an integer array is <strong>good</strong> if:</p>
<ul>
<li>The array is split into three <strong>non-empty</strong> contiguous subarrays - named <code>left</code>, <code>mid</code>, <code>right</code> respectively from left to right.</li>
<li>The sum of the elements in <code>left</code> is less than or equal to the sum of the elements in <code>mid</code>, and the sum of the elements in <code>mid</code> is less than or equal to the sum of the elements in <code>right</code>.</li>
</ul>
<p>Given <code>nums</code>, an array of <strong>non-negative</strong> integers, return <em>the number of <strong>good</strong> ways to split</em> <code>nums</code>. As the number may be too large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,1,1]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> The only good way to split nums is [1] [1] [1].</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [1,2,2,2,5,0]</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> There are three good ways of splitting nums:</p>
<p>[1] [2] [2,2,5,0]</p>
<p>[1] [2,2] [2,5,0]</p>
<p>[1,2] [2,2] [5,0]</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [3,2,1]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> There is no good way to split nums.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>3 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>0 <= nums[i] <= 10<sup>4</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
waysToSplit
public int waysToSplit(int[] nums)
-