GUVI
Back

codekata - doubt

Created 2 years ago
50 Views
1 Comments
RevathiVidhya
@RevathiVidhya
RevathiVidhya
@RevathiVidhyaProfile is locked. Login

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?

Comments
Please login to comment.
 
Powered by habitate.io Habitate