Coding since 11yo, that makes it over 30 years now ~~~
Have a PhD in Comp Sci ~~~
Love to go on bike tours ~~~
I try to stay as generalist as I can in this crazy wide place coding is at now.
A javascript one that has pretty reasonable complexity
functionfindOutlier(integers){// The first three ints can be used to determine whether we are // looking for an odd or an even// If at least two are even, then we're looking for the odd integerconsttypicalIntegerIsEven=isEven(integers[0])+isEven(integers[1])+isEven(integers[2])>=2// Return the first integer that is non-typicalreturnintegers.find(v=>isEven(v)!=typicalIntegerIsEven)// Helper function to determine if a number is even or odd// Note that (-1)%2 === -1 and some integers might be negative.// (-2)%2 === -0 and -0 === 0, so this check will work for any integer.// v&1 is better in many ways, but only goes up to 32 bit intsfunctionisEven(v){returnv%2===0}}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A javascript one that has pretty reasonable complexity