var a = parseInt(userInput[0]);
var b = (userInput[1]);
var c = b.split(' ').map(val=>Number(val))
var d= "";
var e;
for(i=0;i<c.length;i++)
{
for(j=i+1;j<c.length;j++)
{
if(c[i]==c[j])
{
d=d+c[i]+" ";
}
else
{
e=-1;
}
}
}
console.log(e);
console.log(d);
Output Description:
Print the ids which are not unique. Print -1 if all ids are unique
Sample Input :
7
1 1 11 121 131 141 98
Sample Output :
1
Mam i m nt getting proper o/p.
How to use if else inside nested for loop?