Skip to content

Practice Number of Ways to Split Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2270
LeetCode Problem

Number of Ways to Split Array

Problem Statement

Split nums after index i, leaving at least one entry on each side. Count splits for which the left sum is at least the right sum. Return the number of valid indices from 0 through nums.length - 2.

Source: Number of Ways to Split Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [10,4,-8,7]
Output
2

# Example 2

Input
nums = [2,3,1,0]
Output
2

Constraints

2 <= nums.length <= 10^5
-10^5 <= nums[i] <= 10^5

Related LeetCode Problems

Practice more problems similar to Number of Ways to Split Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.