Leetcode 2670. Find the Distinct Difference Array
Given an array nums, return diff where diff[i] = (number of distinct elements in nums[0..i]) minus (number of distinct elements in nums[i+1..n-1]). This is solved by tracking distinct counts for prefixes and suffixes (e.g., with sets) to compute all differences efficiently.
Asked at:
Google
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Late January, 2025
Junior
Problem about intervals and difference array with 2 follow-ups
Hello Interview Premium
Your account is free and you can post anonymously if you choose.