Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Phone Numbers
(version: 0)
Comparing performance of:
Theirs vs Mine
Created:
2 years ago
by:
Registered User
Jump to the latest result
Tests:
Theirs
const L = {'2':"abc",'3':"def",'4':"ghi",'5':"jkl", '6':"mno",'7':"pqrs",'8':"tuv",'9':"wxyz"} var letterCombinations = function(D) { let len = D.length, ans = [] if (!len) return [] const dfs = (pos, str) => { if (pos === len) ans.push(str) else { let letters = L[D[pos]] for (let i = 0; i < letters.length; i++) dfs(pos+1,str+letters[i]) } } dfs(0,"") return ans };
Mine
const phonePad = { 0: [''], 1: [''], 2: ['a', 'b', 'c'], 3: ['d', 'e', 'f'], 4: ['g', 'h', 'i'], 5: ['j', 'k', 'l'], 6: ['m', 'n', 'o'], 7: ['p', 'q', 'r', 's'], 8: ['t', 'u', 'v'], 9: ['w', 'x', 'y', 'z'] }; var letterCombinations = function(...nums) { const first = nums.shift(); const options = nums.reduce((acc, cur) => { let strings = []; for (const str of acc) { for (const letter of phonePad[cur]) { const s = `${str}${letter}`; strings.push(s); } } return strings; }, phonePad[first]); return options; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Theirs
Mine
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Find the stray
Find the stray v2
Find the stray_eric
Find the stray v2b
trailingZeroes removal
Comments
Confirm delete:
Do you really want to delete benchmark?