Ad
  • Custom User Avatar

    Finally a consolation.

  • Custom User Avatar

    [...] if this is something you should strive to be able to do in your own coding or not. and this is 100% a not.
    [...]
    If you ever want to work in a team, this is not the type of code that they will want to see.

    This is exactly the type of code I would like to see in my team's code repository. This code is O(n) time and O(1) space. Could you show me any other, more readable solution, with similar characteristics?
    What I would eventually add would be some comments explaining the algorithm, to account for newbies not really familiar with how binary operator work. But the alrgorithm itself is spot on for the stated problem. It does not waste time, it does not waste space, and XOR operation is one of the most basic ones, on par with arithmetic addition and logical OR.

    If you were to propose a more readable solution, would it be something using the same algorithm as this one? Or some other algorithm with similarly good performance characteristics? Or some totally inferior (performance wise) algorithm which would eat up significantly more memory and/or time?

  • Custom User Avatar

    That's right. People are fucking idiots. Code should be short AND understandable, not just short.

  • Default User Avatar

    had to find the explanation of the code

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I think I agree with u, I tried this solution and I couldnt even make it work, how I am susposed to know what this is about