var maxLevelSum = function(root) {
if(!root){
return 0
}
let res=[]
let queue=[root]
while(queue.length){
let cur=0
let l=queue.length
for(let i=0;i<l;i++){
let node=queue.shift()
cur+=node.val
if(node.left){
queue.push(node.left)
}
if(node.right){
queue.push(node.right)
}
}
res.push(cur)
}
return res.indexOf(Math.max(...res))+1
};
var CQueue = function() {
this.inStack=[]
this.outStack=[]
};
CQueue.prototype.appendTail = function(value) {
this.inStack.push(value)
};
CQueue.prototype.deleteHead = function() {
if(!this.outStack.length){
if(!this.inStack.length){
return -1
}
while(this.inStack.length){
this.outStack.push(this.inStack.pop())
}
}
return this.outStack.pop()
};
var fib = function(n) {
let dp=new Array(n).fill(0)
dp[0]=0
dp[1]=1
for(let i=2
dp[i]=(dp[i-1]+dp[i-2])%(1000000007)
}
return dp[n]
}
var numWays = function(n) {
let dp=new Array(n).fill(0)
dp[0]=1
dp[1]=1
dp[2]=2
for(let i=3
dp[i]=(dp[i-1]+dp[i-2])%1000000007
}
return dp[n]
}