Tap here to switch tabs
Problem
Submissions

Problem: Find the Distinct Difference Array

med
30 min
Try to solve the Find the Distinct Difference Array problem.

Statement

You are given a 00 indexed integer array nums of length n.

The distinct difference array of nums is an array diff of length n where each element diff[i] is equal to the number of distinct elements in the prefix from index 00 to i minus the number of distinct elements in the suffix from index i +1+ 1 to n −1- 1.

Return the array diff.

Note: The prefix includes the element at index i, whereas the suffix does not. When i is equal to n −1- 1, the suffix is empty and contains 00 distinct elements.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤50\leq 50

  • 1≤1 \leq nums[i] ≤50\leq 50

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Distinct Difference Array

med
30 min
Try to solve the Find the Distinct Difference Array problem.

Statement

You are given a 00 indexed integer array nums of length n.

The distinct difference array of nums is an array diff of length n where each element diff[i] is equal to the number of distinct elements in the prefix from index 00 to i minus the number of distinct elements in the suffix from index i +1+ 1 to n −1- 1.

Return the array diff.

Note: The prefix includes the element at index i, whereas the suffix does not. When i is equal to n −1- 1, the suffix is empty and contains 00 distinct elements.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤50\leq 50

  • 1≤1 \leq nums[i] ≤50\leq 50