Skip to content

Practice Number of Great Partitions

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

Hard#2518
LeetCode Problem

Number of Great Partitions

Problem Statement

You are given an array nums consisting of positive integers and an integer k. Partition the array into two ordered groups such that each element is in exactly one group. A partition is called great if the sum of elements of each group is greater than or equal to k. Return the number of distinct great partitions. Since the answer may be too large, return it modulo 10^9 + 7. Two partitions are considered distinct if some element nums[i] is in different groups in the two partitions.

Source: Number of Great Partitions on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,2,3,4], k = 4
Output
6

# Example 2

Input
nums = [3,3,3], k = 4
Output
0

# Example 3

Input
nums = [6,6], k = 2
Output
2

Constraints

1 <= nums.length, k <= 1000
1 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Number of Great Partitions.

Review your practice with PhantomCodeAI

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