79557688

Date: 2025-04-06 00:50:12
Score: 0.5
Natty:
Report link

The Solution with O(n) time complexity to get first unique element from an array.

const nums = [4,2,2,1,3,3]
const result = new Map()
for (const num of nums) {
    result.set(num, (result.get(num) || 0) + 1)
}

const uniqueNum = nums.find((num) => result.get(num) === 1)
console.log(uniqueNum)
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: radhika thakkar