From bb714275dc02e1e88156cd1cff8bfd93308267ea Mon Sep 17 00:00:00 2001 From: IndianBlitz <101599761+IndianBlitz@users.noreply.github.com> Date: Fri, 1 Jul 2022 19:25:02 +0530 Subject: [PATCH 1/6] add newfile OddEven to bits --- Bit-Manipulation/OddEven.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Bit-Manipulation/OddEven.js diff --git a/Bit-Manipulation/OddEven.js b/Bit-Manipulation/OddEven.js new file mode 100644 index 0000000000..6e6fa5a3d1 --- /dev/null +++ b/Bit-Manipulation/OddEven.js @@ -0,0 +1,22 @@ + + + +/* + author: vivek9patel + + + This script will find number is Odd or even + in binary representation of given number + + +*/ +//Check even if true then return 1 else return 0 which means number is odd; +function checkEvenOdd(num){ + 'use strict'; + if((num & 1) === 0) + return 1; + else + return 0; +} + +export {CheckEvenOdd} \ No newline at end of file From 76a0abce0113e4596fcdbb01e87d71b612b7760e Mon Sep 17 00:00:00 2001 From: IndianBlitz <101599761+IndianBlitz@users.noreply.github.com> Date: Fri, 1 Jul 2022 22:16:59 +0530 Subject: [PATCH 2/6] add newfile checkLapindrome to string --- String/checkLapindrome.js | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 String/checkLapindrome.js diff --git a/String/checkLapindrome.js b/String/checkLapindrome.js new file mode 100644 index 0000000000..886ea8a46e --- /dev/null +++ b/String/checkLapindrome.js @@ -0,0 +1,41 @@ + +/* + author:IndianBlitz + This script will check Lapindrome +*/ +// Check for checkLapindrome +function checkLapindrome (str) { + const mid = Math.floor(str.length / 2) + let i = 0 + let j = mid + const part1 = str.slice(i, j).split('').sort().join('') + let part2 + + if ((str.length & 1) === 0) { + part2 = str.slice(j, str.length).split('').sort().join('') + str = part1 + part2 + while (i < mid && j < str.length) { + if (str[i] !== str[j]) { + return 'NO' + }; + + i++ + j++ + } + } else { + i = 0 + j = mid + 1 + part2 = str.slice(j, str.length).split('').sort().join('') + str = part1 + str[mid] + part2 + while (i < mid && j < str.length) { + if (str[i] !== str[j]) { + return 'NO' + }; + i++ + j++ + } + } + return 'YES' + } + export { checkLapindrome } + \ No newline at end of file From 48b52811d0a9c50cca92f3ff2884327dc13cfdbd Mon Sep 17 00:00:00 2001 From: IndianBlitz <101599761+IndianBlitz@users.noreply.github.com> Date: Fri, 1 Jul 2022 22:20:04 +0530 Subject: [PATCH 3/6] Update checkLapindrome.js --- String/checkLapindrome.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/String/checkLapindrome.js b/String/checkLapindrome.js index 886ea8a46e..6f1e07d5fa 100644 --- a/String/checkLapindrome.js +++ b/String/checkLapindrome.js @@ -37,5 +37,4 @@ function checkLapindrome (str) { } return 'YES' } - export { checkLapindrome } - \ No newline at end of file +export { checkLapindrome } From ecb65f4c873db66ee1854e3bed8b7d798159599d Mon Sep 17 00:00:00 2001 From: IndianBlitz <101599761+IndianBlitz@users.noreply.github.com> Date: Fri, 1 Jul 2022 22:25:45 +0530 Subject: [PATCH 4/6] Delete OddEven.js --- Bit-Manipulation/OddEven.js | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 Bit-Manipulation/OddEven.js diff --git a/Bit-Manipulation/OddEven.js b/Bit-Manipulation/OddEven.js deleted file mode 100644 index 6e6fa5a3d1..0000000000 --- a/Bit-Manipulation/OddEven.js +++ /dev/null @@ -1,22 +0,0 @@ - - - -/* - author: vivek9patel - - - This script will find number is Odd or even - in binary representation of given number - - -*/ -//Check even if true then return 1 else return 0 which means number is odd; -function checkEvenOdd(num){ - 'use strict'; - if((num & 1) === 0) - return 1; - else - return 0; -} - -export {CheckEvenOdd} \ No newline at end of file From dc92cded790ac5cac4caf9c64b030baa1a9d3f9e Mon Sep 17 00:00:00 2001 From: IndianBlitz <101599761+IndianBlitz@users.noreply.github.com> Date: Fri, 1 Jul 2022 22:32:50 +0530 Subject: [PATCH 5/6] Update checkLapindrome.js --- String/checkLapindrome.js | 60 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/String/checkLapindrome.js b/String/checkLapindrome.js index 6f1e07d5fa..59cb11a7df 100644 --- a/String/checkLapindrome.js +++ b/String/checkLapindrome.js @@ -1,40 +1,38 @@ - /* author:IndianBlitz This script will check Lapindrome */ // Check for checkLapindrome -function checkLapindrome (str) { - const mid = Math.floor(str.length / 2) - let i = 0 - let j = mid - const part1 = str.slice(i, j).split('').sort().join('') - let part2 - - if ((str.length & 1) === 0) { - part2 = str.slice(j, str.length).split('').sort().join('') - str = part1 + part2 - while (i < mid && j < str.length) { - if (str[i] !== str[j]) { - return 'NO' - }; - - i++ - j++ +function checkLapindrome(str) { + const mid = Math.floor(str.length / 2); + let i = 0; + let j = mid; + const part1 = str.slice(i, j).split("").sort().join(""); + let part2; + if ((str.length & 1) === 0) { + part2 = str.slice(j, str.length).split("").sort().join(""); + str = part1 + part2; + while (i < mid && j < str.length) { + if (str[i] !== str[j]) { + return "NO"; } - } else { - i = 0 - j = mid + 1 - part2 = str.slice(j, str.length).split('').sort().join('') - str = part1 + str[mid] + part2 - while (i < mid && j < str.length) { - if (str[i] !== str[j]) { - return 'NO' - }; - i++ - j++ + i++; + j++; + } + } + else { + i = 0; + j = mid + 1; + part2 = str.slice(j, str.length).split("").sort().join(""); + str = part1 + str[mid] + part2; + while (i < mid && j < str.length) { + if (str[i] !== str[j]) { + return "NO"; } + i++; + j++; } - return 'YES' } -export { checkLapindrome } + return "YES"; +} +export { checkLapindrome }; From 3507b749d72a1eaf6cfdd7608ea2f2c47f70a6f2 Mon Sep 17 00:00:00 2001 From: IndianBlitz <101599761+IndianBlitz@users.noreply.github.com> Date: Fri, 1 Jul 2022 22:35:27 +0530 Subject: [PATCH 6/6] Update checkLapindrome.js --- String/checkLapindrome.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/String/checkLapindrome.js b/String/checkLapindrome.js index 59cb11a7df..47f8d4158d 100644 --- a/String/checkLapindrome.js +++ b/String/checkLapindrome.js @@ -2,7 +2,7 @@ author:IndianBlitz This script will check Lapindrome */ -// Check for checkLapindrome +// Check for checkLapindrom function checkLapindrome(str) { const mid = Math.floor(str.length / 2); let i = 0;