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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 30 Days of Code
  4. Day 29: Bitwise AND
  5. Discussions

Day 29: Bitwise AND

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

    You are viewing a single comment's thread. Return to all comments →

  • lemmings125
    6 years ago+ 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 ???

    23|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature