This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uniqueNumber = (arr:number[]):number => arr.reduce((x,y) => x^y); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const twoSum = (numbers:number[], k: number): Boolean => { | |
const rec:Record<number,number>= {}; | |
for(const n of numbers){ | |
rec[n] = n; | |
if(rec.hasOwnProperty(k-n)) return true; | |
} | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Valid Parentheses | |
* @param {string} s | |
* @return {boolean} | |
*/ | |
const validParentheses = (s) => { | |
if (s === null || !s.length) return true; | |
const chars = s.split(''); | |
const stack = []; |
NewerOlder