Amazon Care Get Minimum Score
Given an array of integers and two specified numbers, find a subarray from the original array that contains both of these specified numbers, with the requirement that the subarray contains the minimum number of distinct numbers. Return the count of distinct numbers in this subarray.
If the two specified numbers are the same, simply return 1 if the array contains this number, otherwise return 0.
Complete the function findSubarrayWithMinimumDistinctIntegers in the editor.
findSubarrayWithMinimumDistinctIntegers has the following parameters:
- 1.
int[] array: an array of integers - 2.
int series1: the first specified number - 3.
int series2: the second specified number
Returns
int: the count of distinct numbers in the subarray
1Example 1
2Example 2
3Example 3
4Example 4
Constraints
Limits and guarantees your solution can rely on.
๐๐