Data Structures & AlgorithmsHardTCS NQT · Accenture
Starting from an empty deque, the operations are: push front 1, push back 2, push front 3, pop back, push back 4. Let the deque contents after these operations be D. What is the value of sum(D) * 10 + D[0] (front first)?
- A. 93
- B. 76
- C. 83
- D. 166
Correct answer: C. 83
Track the front and back carefully: push front 3 places it before 1, pop back removes 2, and push back 4 ends the list. The front element of the final deque is 3.
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
- A robot starts at position 0 on a number line. For each move it steps right (R) or left (L). Count the number of distinct positions…
- A text cursor starts after the text abc (cursor at the end). Operations in order: type x, Left, Left, Backspace, Right, type y. Here Left…
- How many integers x with 1 <= x <= 500 satisfy x mod 7 = x mod 11?
- How many ordered pairs (i, j) with 1 <= i, j <= 20 have i^2 + j^2 divisible by 5?
- How many integers x with 1 <= x <= 600 are divisible by 4 or 6 but not by 12?
- How many contiguous subarrays of [6, 12, 18, 8, 4] have gcd exactly equal to 2?