ProgrammingHardTCS NQT · Infosys
How many index pairs i < j in the array {3, 5, 3, 5, 7} satisfy a[i] XOR a[j] == 0?
- A. 3
- B. 2
- C. 1
- D. 4
Correct answer: B. 2
a[i] XOR a[j] is 0 exactly when the values are equal. The value 3 appears twice and 5 appears twice, giving two pairs.
More C Programming questions
- How many integers from 1 to 30 are multiples of 8?
- A circular buffer of size n = 5 steps back from index 0 with (idx + n - 1) % n. What index results?
- A qsort comparator orders the elements in descending order. After sorting {5, 9, 2}, what is the first element?
- uint32t x = 491u; What is (x >> 3) & 7? (491 is 0x1EB.)
- uint32t r = 2147483648u % 1000u; What is r?
- uint32t p = 65536u 65537u; What is p?