Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
In [6, 3, 6, 9, 3, 9, 9, 5, 5] exactly one value appears an odd number of times and every other value appears an even number of times. What is that value?
- A. 10
- B. 11
- C. 3
- D. 9
Correct answer: D. 9
XOR cancels pairs, so the total XOR equals the value appearing an odd number of times. Here 9 appears three times and is the odd one out.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many index pairs i < j in [12, 21, 30, 43, 66, 111, 3] have equal decimal digit sums?
- How many ordered index pairs (i, j) in [1, 3, 4, 7, 10, 12, 15] satisfy a[j] - a[i] = 3?
- How many integers from 1 to 10000 inclusive are multiples of 7 whose decimal digit sum is exactly 7?
- For "aabaabaa", how many indices i >= 1 have Z-function value exactly 2?
- How many ordered pairs (a, b) of integers with a >= 2 and b >= 2 satisfy a b = 36?
- Moving one unit per step, what is the minimum total number of unit moves to make every element of [1, 2, 9, 10, 12] equal to a common…