Skip to content

Practice Maximize Count of Distinct Primes After Split

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

Hard#3569
LeetCode Problem

Maximize Count of Distinct Primes After Split

Problem Statement

Process updates [idx, val] on nums in order, keeping each change for later queries. After setting nums[idx] to val, split the array between two entries into nonempty parts. Count distinct prime values separately in each part and add the two counts; a prime occurring on both sides counts once in each side. Return the maximum such sum for every update.

Source: Maximize Count of Distinct Primes After Split on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [2,1,3,1,2], queries = [[1,2],[3,3]]
Output
[3,4]

# Example 2

Input
nums = [2,1,4], queries = [[0,1]]
Output
[0]

Constraints

2 <= n == nums.length <= 5 * 10^4
1 <= queries.length <= 5 * 10^4
1 <= nums[i] <= 10^5
0 <= queries[i][0] < nums.length
1 <= queries[i][1] <= 10^5

Related LeetCode Problems

Practice more problems similar to Maximize Count of Distinct Primes After Split.

Review your practice with PhantomCodeAI

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