Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Created October 3, 2021 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/d7e62748dc52a66826fe53e3d9aa0600 to your computer and use it in GitHub Desktop.
Save YonatanKra/d7e62748dc52a66826fe53e3d9aa0600 to your computer and use it in GitHub Desktop.
function singleNumber(nums) {
for (let i = 0; i < nums.length; i++) {
let found = false;
for (let j = 0; j < nums.length; j++) {
if (nums[j] === nums[i] && i != j) {
found = true;
break;
}
}
if (!found) return nums[i];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment