Tap here to switch tabs
Problem
Submissions

Problem: Number of Unique Flavors After Sharing K Candies

med
30 min
Try to solve the Number of Unique Flavors After Sharing K Candies problem.

Statement

You are given an integer array candies, where each element candies[i] represents the flavor of the ii-th candy. You are also given an integer k.

You need to give away a contiguous sequence of kk candies to your friend. After sharing these candies, you keep all the remaining candies.

Return the maximum number of unique flavors you can have among the remaining candies.

Constraints:

  • 0≤0 \leq candies.length ≤105\leq 10^5

  • 1≤1 \leq candies[i] ≤105\leq 10^5

  • 0≤0 \leq k ≤\leq candies.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Unique Flavors After Sharing K Candies

med
30 min
Try to solve the Number of Unique Flavors After Sharing K Candies problem.

Statement

You are given an integer array candies, where each element candies[i] represents the flavor of the ii-th candy. You are also given an integer k.

You need to give away a contiguous sequence of kk candies to your friend. After sharing these candies, you keep all the remaining candies.

Return the maximum number of unique flavors you can have among the remaining candies.

Constraints:

  • 0≤0 \leq candies.length ≤105\leq 10^5

  • 1≤1 \leq candies[i] ≤105\leq 10^5

  • 0≤0 \leq k ≤\leq candies.length