Ad
  • Custom User Avatar

    Also, don't post your solutions publicly, they'll get indexed by search engines which will let people cheat by copying them.

  • Default User Avatar

    please use some common sense when you post issues: at least mention a test case for which you think the reference solution is incorrect (with the input value, the expected value and your own answer). i just pasted your solution in the trainer, after running i immediately see:

    Incorrect answer for n=1, expected 2, but got 3
    

    converted to binary: 1 --> 10 but you returned 11


    Note that your code uses a global variable numberOf1 to maintain state, that's very bad practice. global variables keep their values between function calls. The tests call your function several times in a row.