AlexZhang11

Results 16 comments of AlexZhang11

```markdown function MinStack(){ this.stack = [] this.stack2 = [] } MinStack.prototype.push = function(val){ this.stack.push(val) if(this.stack2.length==0||this.stack2[this.stack2.length-1]>val){ this.stack2.push(val) } } MinStack.prototype.pop = function(){ if(this.stack.pop()===this.stack2[this.stack2.length-1]){ this.stack2.pop() } } MinStack.prototype.top = function(){ return this.stack[this.stack.length-1]...

function getMostChar(str){ let i = 0 let obj = [] while(i

```markdown function getMostChar(str){ let i = 0 let obj = {} while(imaxValue){ res={} maxValue = obj[key] res[key] = obj[key] }else{ if(obj[key]==maxValue){ res[key] = obj[key] } } } return res }...

```markdown let mapBrackets = { "(":")", "[":"]", "{":"}", } function validBrackets(str){ let stack = [] for(let i = 0;i

function fn(nums){ let maxcontinueUpCount=1,maxcontinueUpCountValue = 1; let maxBreakUpCount= 1,maxBreakUpCountValue =1 let i = 1 while(inums[i-1]){ if(maxBreakUpCountValue

```markdown function getMostNumber(str){ let reg = /^[+-]?[0-9]*/ str = str.trimStart() let temp =str.match(reg) console.log(reg.exec(str),str.match(reg),temp,'temp') let max =Math.pow(2,31) let min = -max-1 if(tempmax){ return max } if(!temp){ return 0 } return...

```markdown let map={ '}':'{', ']':'[', ')':'(', } function fn(str){ let stack = [] let stack2 = [] let res = {} for(let i = 0;i{ let list = it.split('-') res[list[0]]...

```markdown function getMultiply(str1,str2){ let total = 0 let count = 0 for (let i =str1.length-1;i>=0;i--){ let c = (str1.charAt(i))*1 let s2 = str2*1 let res = c*s2*Math.pow(10,count) count++ total+=res }...

```markdown function getMostNoRepeatChar(str){ let obj = {} let maxLen = 0 let curCount = 0 for (let i=0;imaxLen?curCount:maxLen curCount = 0 obj={} i-- }else{ obj[str.charAt(i)] = true curCount++ } }...

```markdown function charSum(num1,num2){ let i = num1.length-1; let j = num2.length-1; let k = '' while(i>=0&&j>=0){ let n1 = num1.charAt(i)%10 let n2 = num2.charAt(j)%10 let total =n1+n2 k = total+k...