dimanche 26 septembre 2021

Binary number pattern matching

/*

  • patternMatching - return the number of found 4-bit pattern p in the given 16-bit number x.
  • Examples:
  •         patternMatching(11, 11) = 1, patternMatching(245, 13) = 1,
    
  •         patternMatching(170, 15) = 0, patternMatching(23397, 11) = 3
    
  • Legal ops: ! ~ & ^ | + << >>
  • Max ops: 75
  • Rating: 4 */ How to solve this question...? Should I just iterate each bit one by one?

Aucun commentaire:

Enregistrer un commentaire