GUVI
Back

Given 2 numbers N and K followed by elements of N .Print 'yes' if K exists else print 'no'. Sample Testcase : INPUT 4 2 1 2 3 3 OUTPUT yes

13 Views
1 Comments

NishantyQR4TY
NishantyQR4TY 2 weeks ago
NishantyQR4TY
@NishantyQR4TYProfile is locked. Login

// Getting input via STDIN

const readline = require("readline");

const inp = readline.createInterface({

input: process.stdin

});

const userInput = [];

inp.on("line", (data) => {

userInput.push(data);

});

inp.on("close", () => {

//start-here

//Your code goes here … replace the below line with your code logic

var a = userInput[0].split(" ")

var elements = userInput[1].split(" ")

var N = a[0]

var K = a[1]

for(var i = 0;i<elements.length;i++)

if(K===elements[i])

{

console.log("yes")

}

else

{

console.log("no")

//end-here

});

Comments
Please login to comment.
 
Habitate.io