Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
Replace every element simultaneously by (a[i] + a[i-1]) mod 10, indices cyclic, on [1, 2, 3, 4]. What is the resulting array?
- A. 1 3 5 7
- B. 4 3 5 7
- C. 5 3 4 7
- D. 5 3 5 7
Correct answer: D. 5 3 5 7
Compute each new value from the original neighbour (the update is simultaneous): position 0 uses a[3] = 4 giving 5, and so on. Updating in place from left to right changes later values.
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
- Activities (start, finish) are [(1, 4), (3, 5), (0, 6), (5, 7), (3, 9), (5, 9), (6, 10), (8, 11), (8, 12), (2, 14), (12, 16)]. Two…
- Meetings (start, end) are [(0, 30), (5, 10), (15, 20), (25, 40), (35, 50), (45, 60), (50, 55)]. A room can host one meeting at a time, and…
- Balloons span the closed intervals [(1, 6), (2, 8), (7, 12), (10, 16), (3, 5), (14, 15), (8, 9)] on a horizontal line. An arrow shot at…
- Unit-time jobs are given as (deadline, profit): [(2, 100), (1, 19), (2, 27), (1, 25), (3, 15)]. Each job takes one time slot starting at…
- Jobs as (processing time, weight) are [(3, 2), (2, 1), (4, 4), (1, 3)]. They run one at a time with no idle time, and the cost is the sum…
- Tasks AAABBBCCD (each letter is a task, one unit of time each) run on a single CPU. Two identical tasks must be separated by at least n =…