Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Good Partitions

Count the Number of Good Partitions asks you to split an array into contiguous subarrays so that no value appears in two different parts, then return the count modulo a large prime.

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

Count the Number of Good Partitions asks you to split an array into contiguous subarrays so that no value appears in two different parts, then return the count modulo a large prime.

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