Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
hgftyguhijokpl[;]
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Solution next day
37881.1 Ops/sec
Solution on interview
28735.9 Ops/sec
Script Preparation code:
const ALPHABET = 'abcdefghijklmnopqrstuvwxyz' const makeSet = () => { const count = Math.round(Math.min(Math.random() * 4 + 1, ALPHABET.length)) let out = [] for (let i = 0; i < count; i++) { let char do char = ALPHABET[Math.floor(Math.random() * ALPHABET.length)] while (out.includes(char)) out.push(char) } return out.sort().join('') } const shuffleSet = (set) => { let out = ' '.repeat(Math.round(Math.random() * (set.length * 2) + 3)) for (const char of set) { const count = Math.round(Math.random() * 3 + 1) for (let j = 0; j < count; j++) { const idx = Math.floor(Math.random() * out.length) out = out.slice(0, idx) + char + out.slice(idx) } } return out } const makeCase = () => { const filler = makeSet() let answer do { answer = makeSet() } while (answer === filler) answer = shuffleSet(answer) const count = Math.random() * 6 + 4 const input = [] for (let i = 0; i < count; i++) input.push(shuffleSet(filler)) input.splice(Math.floor(Math.random() * input.length), 0, answer) return { input, answer } } var cases = [ makeCase(), makeCase(), makeCase(), ]
Tests:
Solution next day
function findUniq(strings) { const uniq = {} for (let i = 0; i < strings.length; i++) { const l = new Set(strings[i].replace(/\s+/g, '').toLowerCase()).size uniq[l] = !(l in uniq) ? strings[i] : null } return Object.values(uniq).find(v => v) } for (const { input, result } of cases) console.assert(findUniq(input) === result)
Solution on interview
function findUniq(strings) { const s1 = strings.map((s) => s.toLowerCase().replaceAll(/\s/g, '')) const s2 = s1.map((s) => [...new Set(s)].sort().join('')) let out = [] for (let i = 0; i < s2.length; i++) { const elm = s2[i] if (out.some((idx) => s2[idx] === elm)) out = out.filter((idx) => s2[idx] !== elm) else out.push(i) } return strings[out[0]] } for (const { input, result } of cases) console.assert(findUniq(input) === result)