AmazonOA #190
Amazon Care Get Minimum Score
Estimated MediumJudge-ready
Topics (AI-labelled)Two PointersHashing
Find the minimum number of distinct values in a non-empty contiguous subarray that contains both target values; if the two targets are equal, output 1 if the value occurs and 0 otherwise. This site adds that 0 is output whenever no valid subarray exists.
Input
The first line contains n u v; the second line contains the array. This site uses 1≤n≤200000, with array values and targets in −10^9..10^9.
Output
Output a single integer, the answer.
Example 1
Input:
6 1 5
1 2 2 2 5 2
Output:
3
Example 2
Input:
5 1 2
1 3 2 1 4
Output:
2
Example 3
Input:
3 1 1
2 4 9
Output:
0
Example notes
The answers are 3, 2 and 0.
Editorial
Loading solution…