Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by Array ( 6 years ago )
package lec02;
import java.util.Scanner;
public class Array {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int k = scanner.nextInt();
int a[] = new int[n];
for (int i = 0; i < n; i++) {
a[i] = scanner.nextInt();
}
int count[] = new int[100000];
int left = 1;
int right = 0;
int dif = 0;
while (right < n) {
if (count[a[right]] == 0)
dif++;
count[a[right]]++;
right++;
while (dif == k) {
if (count[a[left - 1]] == 1) {
System.out.println(left + " " + right);
System.exit(0);
}
count[a[left]]--;
left++;
}
}
System.out.println(-1 + " " + -1);
}
}
Revise this Paste