Last active
June 11, 2017 05:37
-
-
Save blackmiaool/16b0d71a9ed704ec28a34e7bc1141f63 to your computer and use it in GitHub Desktop.
leetcode tools
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 A=(function (){ | |
const cache={}; | |
return function(num,base){ | |
const key=num+'-'+base; | |
if(cache[key]){ | |
return cache[key]; | |
} | |
let ret=1; | |
for(var i=0;i<num;i++){ | |
ret*=base-i; | |
} | |
cache[key]=ret; | |
return ret; | |
} | |
})(); | |
const C=(function (){ | |
const cache={}; | |
return function(num,base){ | |
const key=num+'-'+base; | |
if(cache[key]){ | |
return cache[key]; | |
} | |
let ret=A(num,base); | |
for(var i=2;i<=num;i++){ | |
ret/=i; | |
} | |
cache[key]=ret; | |
return ret; | |
} | |
})(); |
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 map={}; | |
const farr=[]; | |
nums.forEach(function(v,i){ | |
if(!map[v]){ | |
map[v]=0; | |
farr.push(v); | |
} | |
map[v]++; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment