Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many contiguous subarrays of [1, 2, 4, 3, 6] have a bitwise OR equal to exactly 7?

  1. A. 7
  2. B. 8
  3. C. 10
  4. D. 2

Correct answer: B. 8

The OR only grows as a subarray extends, so a brute force over start and end indices counts exactly the subarrays whose OR equals 7. Targeting 6 instead is a different count.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic