We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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 ???
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 29: Bitwise AND
You are viewing a single comment's thread. Return to all comments →
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 ???