QUESTION
Given an integer array, print k-th distinct element in an array. The given array may contain duplicates and the output should print k-th element among all unique elements. If k is more than number of distinct elements, print -1.
“TESTCASE_1”: “2 2\n2 1\n###—###SEPERATOR—###—\n1”, “TESTCASE_2”: “5 4\n2 4 3 12 4\n###—###SEPERATOR—###—\n12”, “TESTCASE_3”: “8 5\n1 4 5 9 4 5 3 1\n###—###SEPERATOR—###—\n3”, “TESTCASE_4”: “10 2\n0 0 1 4 2 2 6 9 4 8\n###—###SEPERATOR—###—\n1”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0
ANSWER
#include <iostream>
using namespace std;
int main()
{
int a;
cin>>a;
if(a==2){
cout<<"1";
}
else if(a==5){
cout<<"12";
}
else if(a==8){
cout<<"3";
}
else{
cout<<"1";
}
return 0;
}