Ad
  • Custom User Avatar

    TypeScript translation added

  • Custom User Avatar

    In JS and TS I assume that it should work for the whole range represented by number so I would include testcase containing a number larger than 2147483647 (Math.pow(2,31) - 1) ie.

    doTest([2147483648, 1, 1, 2, 2, 2, 2], 2147483648)

  • Custom User Avatar

    This solution is clever but since it's not included in the description I assume that it should work for the whole range represented by number in JS. Because bitwise operators in JS operate on signed 32-bit integer this solution won't work for any number larger than 2147483647 (Math.pow(2,31) - 1).

    findOdd(2147483647, 1, 1, 2, 2, 2, 2) // works fine
    findOdd(2147483648, 1, 1, 2, 2, 2, 2) // returns -2147483648