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

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • 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 →

  • fran_mahon
    3 months ago+ 2 comments

    Python

    def bitwiseAnd(N, K):
        max_val = 0
        for i in range(K-2,N):
            for j in range(i+1,N+1):
                val = i&j
                if val == K-1:
                    return val
                if max_val<val<K:
                    max_val = val
        return max_val
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy