Ad
  • Custom User Avatar

    In a computer you have bits. They use binary (1 or 0, on or off).
    By combining these, we can begin to go from 1 to much higher numbers.
    it is read right to left as powers of 2.
    example:
    0 0 0 0 0 // is really equal to
    16 8 4 2 1 // this

    So when a bit is "on" or "1", it will count the code below
    EX:
    0 0 1 0 1 //
    16 8 4 2 1

    This turns on 1 and 4 this equals 5.

    1 1 1 1 1
    16 8 4 2 1

    This has 16+8+4+2+1 which equals 31

    0 1 0 0 1 //
    16 8 4 2 1 //

    in this case 8 is on and 1 is on, so 8+1 = 9

    This should be sufficent instruction to help you pass this.
    PS I realize this is old, but others may ask.

  • Custom User Avatar

    Only because of the exponent = 3
    Otherwise, you could do a arr.length-1 and it would easily work for EVERY instance you could throw at it up to memory limits.

  • Custom User Avatar

    Yes officer. This code right here!