Given a number N, print the odd digits in the number(space seperated) or print -1 if there is no odd digit in the given number.
Input Size : N <= 100000
Sample Testcase :
INPUT
2143
OUTPUT
1 3
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => {
var data = userInput[0].split(" ");
var a = (data[0]);
var b = a.split('');
var c=[];
for(i=0;i<b.length;i++)
{if(Number(b[i])%2!==0)
c[i]=b[i]
else
c[i]=0}
for(i=0;i<c.length;i++)
d=c.join("");
e=d.replace(/0/g,' ')
console.log(e);
});
Input Size : N <= 100000
Sample Testcase :
INPUT
2143
OUTPUT
1 3
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => {
var data = userInput[0].split(" ");
var a = (data[0]);
var b = a.split('');
var c=[];
for(i=0;i<b.length;i++)
{if(Number(b[i])%2!==0)
c[i]=b[i]
else
c[i]=0}
for(i=0;i<c.length;i++)
d=c.join("");
e=d.replace(/0/g,' ')
console.log(e);
});
Comments
Post a Comment