js array value that appears odd number of times

Solutions on MaxInterview for js array value that appears odd number of times by the best coders in the world

showing results for - "js array value that appears odd number of times"
Farah
16 Sep 2018
1// Find the odd int
2function findOdd(A) {
3  return A.reduce((a, b) => a ^ b);
4}
5
6console.log(findOdd([20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5], 5)); // 5
7console.log(findOdd([1,1,2,-2,5,2,4,4,-1,-2,5], -1)); // -1
8console.log(findOdd([20,1,1,2,2,3,3,5,5,4,20,4,5], 5)); // 5
Mariana
03 Aug 2016
1function findOdd(A) {
2    let counts = A.reduce((p, n) => (p[n] = ++p[n] || 1, p), {});
3    return +Object.keys(counts).find(k => counts[k] % 2) || undefined;
4}
queries leading to this page
given an array find the integer that appears an odd number of times javascriptcount the number of even numbers in an array jshow do i return the one od number of times in a js aray 3fgiven an array 2c find the int that appears an odd number of times there will always be only one integer that appears an odd number of times ruby find number appear appear an odd number times arrayjavascript check odd numbers in arrayreturn odd numbers in array javascriptfind an odd number in list of numbers javascriptjavascript function that return the odd numbers in arrayjavascript given an array of integers 2c find the one that appears an odd number of times there will always be only one integer that appears an odd number of times odd numbers item in javascript arraygiven an array 2c find the integer that appears an odd number of times there will always be only one integer that appears an odd number of times phpjavascript given an array of integers 2c find the one that appears an odd number of times how to calculate array odd numbers injsin odd number length array how to get mid index in javascripthow to only get odd numbers from an arrayjavascriptgiven an array of integers 2c find the one that appears an odd number of times in jscheck number of even number in an array in javascriptgiven an array 2c find the integer that appears an odd number of times there will always be only one integer that appears an odd number of timesgiven an array of integers 2c find the one that appears an odd number of times pythonhow to find odd number of times in javascriptgiven an array 2c find the int that appears an odd number of times pythonjs array value that appears odd number of timeshow to get all the values in odd position in an array jshow to check if numbers is even or odd in array javascriptjavascript given array of integers find one that appears an odd number of timesfind number that appears odd number of time in array javascriptfunction that checks array for odd numbers jsgiven an array 2c find the int that appears an odd number of times find the element that appears an odd number of times in an array javascripthow to check if a number is repeated odd times in an array in javascriptruby find number appear an odd number times arrayreturn an array that contains all the odd numbers using a while loop jshow to find the count of odd numbers in an array javascriptcheck if only one value is odd in array jssearch in array javascript how many item that appears an odd number of times given an array find the int that appears an odd number of times javascriptcheck to see if an array includes an odd number jscount odd numbers in array javascriptgiven an array 2c find the integer that appears an odd number of times javascriptfind value that occurs in odd number of elements jsjavascript find odd number of integers in an arrayhow to find odd numbers in an array javascriptgiven an array of integers 2c find the one that appears an odd number of times 27js 27find odd numbers in an array javascriptremove odd numbers from array javascriptruby find number appear appear an odd number timescheck if number appears odd number of times in array javascript count odd number items in array javascriptruby find odd number times arrayarray items odd number of timeshow to show odd numbers in array in function jsgiven an array of integers find the one that appears an odd number of times javascriptjavascript function to count all odd numbers in an arraygiven an array 2c find the integer that appears an odd number of times given an array 2c find the integer that appears an odd number of times in jscheck if one value is odd in array jshow i display only odd times jsreturn number of odd numbers in an array javascriptgiven an array of integers 2c find the one that appears an odd number of timesgiven an array of integers 2c find the one that appears an odd number of times there will always be only one integer that appears an odd number of times find odd numbers in array javascriptarray that finds odd numbers jsgiven an array 2c find the int that appears an odd number of timesfind integer appear odd times in an array javascriptfind the one odd or even number out of elements in an array jshow to find the odd numbers in an array javascriptcount odd numbers in an array javascripthow to calculate array odd numbers in jsjavascript to check if consecutive elements of an array are not oddreturn an array that contains all the odd numbers between 3 and 103 jsjs array value that appears odd number of times