• + 1 comment

    i solved this problemi in O(n^2) but on reading the editorial the problem setters code solved this in constant time using the bitwise NOT and bitwise OR operator.

    It works and solves correctly when a set contains the numbers as detailed in the constraints {1,2,3 ... N} but how do coders come up with these algorithms.

    I want to advance my coding skills but I would never have found a solution like that, it makes sense when I code it or put it on pen and paper and use binary but how are these algorithms found ???