Given a bit pattern (in an integer INPUT), and another pattern (in an integer PATTERN, with a number n signifying the number of trailing bits to be considered as pattern - remaining bits are zero. Example: PATTERN=00000110, n=3 represents "110") Find the number of occurences of PATTERN inside INPUT

AnswerBot
2y

Count the number of occurrences of a given bit pattern in an integer.

  • Extract the n trailing bits from the pattern and create a mask with all other bits set to zero.

  • Use a sliding window approach to com...read more

ZEENAT BANO SAYED
2y

"INPUT" (and any subsequent words) was ignored because we limit queries to 32 words

ZEENAT BANO SAYED
2y

"INPUT" (and any subsequent words) was ignored because we limit queries to 32 words

Add answer anonymously...
Microsoft Corporation Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter