Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the sum of a XOR (a >> 1) over a = 5, 8 and 13 (where >> is a right shift by one bit)?
- A. 31
- B. 62
- C. 26
- D. 30
Correct answer: D. 30
Gray code of a is a XOR (a >> 1): 5 gives 7, 8 gives 12, and 13 gives 11. The total is 30, which is a different quantity from the shifted-left variant.
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 [2, 5, 4, 10, 3, 15] have a product that is a multiple of 10?
- With weight limit 15, what is the maximum number of items from [5, 3, 8, 2, 7, 4] you can carry (choose any subset)?
- How many integers from 1 to 500 inclusive are divisible by 4 but not by 6?
- How many different output orders can a stack produce from the input 1, 2, 3, 4 pushed in order?
- In "abccbaxyz", take the longest palindromic substring (the first one if tied) and count its distinct characters.
- In "abcdbefg", what is the 0-based index of the first character that repeats an earlier character?