My Channel -> Click Here
My Technical Subscription List Youtube - Where I Learn Everyday
https://www.youtube.com/c/akshaymarch7
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"; | |
} | |
} |
/** | |
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. |
My Channel -> Click Here
My Technical Subscription List Youtube - Where I Learn Everyday
https://www.youtube.com/c/akshaymarch7
window.alert('HI from gist world! YALGAAR'); |
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++; |