Skip to content

Instantly share code, notes, and snippets.

View 2manoj1's full-sized avatar
🎭
Lets connect

Manoj Mukherjee 2manoj1

🎭
Lets connect
View GitHub Profile
const zipCodePattern = /^(0{4}[1-9]|0{3}[1-9]\d|0{2}[1-9]\d{2}|0[1-9]\d{3}|[1-9]\d{4}|99950)$/;
function checkAddress(address) {
if (zipCodePattern.test(address)) {
return "Valid ZIP code";
} else {
return "Not a valid ZIP code";
}
}
@2manoj1
2manoj1 / arrSumReduceExampel.js
Last active July 22, 2022 09:06
Basketball Turing test solution JS
/**
You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds' scores.
At the beginning of the game, you start with an empty record. You are given a list of strings ops, where ops[i] is the ith operation you must apply to the record and is one of the following:
An integer x - Record a new score of x.
"+" - Record a new score that is the sum of the previous two scores. It is guaranteed there will always be two previous scores.
"D" - Record a new score that is double the previous score. It is guaranteed there will always be a previous score.
"C" - Invalidate the previous score, removing it from the record. It is guaranteed there will always be a previous score.
Return the sum of all the scores on the record. The test cases are generated so that the answer fits in a 32-bit integer.
@2manoj1
2manoj1 / youtubeLearning.md
Last active May 31, 2022 03:42
My Technical Subscription List Youtube - Where I Learn Everyday - Tech KnowledgeBase
window.alert('HI from gist world! YALGAAR');
@2manoj1
2manoj1 / mergeSortZeroTail.js
Last active April 27, 2020 14:28
All zero at tail of array
const a0 = [2, 0, 3, 4, 5, 4, 0, 0, 0, 3, 0, 2, 8, 9, 0, 0, 1, 1, 0];
const a1 = [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, -1];
const a2 = [0, 0, 0, 2, 2, 2, 2, 2, 2, 2];
const merge = (left, right) => {
let resArr = [], zeroArr = [], lIndex = 0, rIndex = 0;
while (lIndex < left.length && rIndex < right.length) {
if (left[lIndex] === 0) {
zeroArr.push(0);
lIndex++;