Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Good Partitions

med
30 min
Try to solve the Count the Number of Good Partitions problem.

Statement

You are given an array of positive integers nums.

A partition of an array into one or more contiguous subarrays is considered good if no two distinct subarrays contain the same value.

Return the total number of good partitions of nums. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Good Partitions

med
30 min
Try to solve the Count the Number of Good Partitions problem.

Statement

You are given an array of positive integers nums.

A partition of an array into one or more contiguous subarrays is considered good if no two distinct subarrays contain the same value.

Return the total number of good partitions of nums. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9