From fb26757cb1ad6af7406339d7e8c9208f619500b2 Mon Sep 17 00:00:00 2001 From: Arunkumar1712 <116170537+Arunkumar1712@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:01:42 +0530 Subject: [PATCH] Swaps in arrays Given a string 'S' swap the even and odd characters starting from index 1(Assume the index starts from 0). Input Size : |s| <= 10000000(complexity O(n)) Sample Testcase : INPUT codekata OUTPUT ocedakat --- test.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test.js diff --git a/test.js b/test.js new file mode 100644 index 0000000..82f9615 --- /dev/null +++ b/test.js @@ -0,0 +1,29 @@ + +// 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", () => { + let a=userInput[0].split(""); + let temp=0; + for( var i=0;i