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
Created 2 years ago
308
Views
1
Comments
// 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
});