Data Structures & AlgorithmsVery hardGATE CS · TCS NQT
Every element of the circular array [1, 2, 3, 4] is replaced by the sum of its two circular neighbours, taken modulo 10, simultaneously. Do this 2 times. What is the value at index 0 afterwards?
- A. 9
- B. 8
- C. 10
- D. 12
Correct answer: B. 8
Compute the whole new array after each round before replacing values; updating in place mixes old and new values. After round one the array is 6, 4, 6, 4.
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 pairs a < b with 1 <= a < b <= 12 satisfy gcd(a, b) = b - a?
- How many integers n in [1, 60] satisfy n^2 - n divisible by 6?
- What is the length of the longest contiguous subarray of [4, 3, 2, 6, 1, 5] whose sum is at most 10?
- How many times does the pattern aab occur in the string aabaabaab, counting overlapping matches?
- How many pairs (a, b) with 1 <= a <= b <= 12 satisfy lcm(a, b) > 36?
- Treat [4, -1, 5, -6, 3] as circular. Over all contiguous circular windows of length 1 to 5, what is the maximum window sum?