Data Structures & AlgorithmsModerateTCS NQT · Infosys
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 and Right move the cursor one character, and Backspace deletes the character before the cursor. What is the length of the final text?
- A. 4
- B. 3
- C. 5
- D. 6
Correct answer: A. 4
Simulate the cursor position explicitly: typed characters go in at the cursor, not at the end. The text becomes abcx, then acx, then acyx, so its length is 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 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?
- What is the least common multiple of the integers 2 through 20, reduced modulo 1000000007?
- How many contiguous subarrays of [2, 5, 3, 4, 10] have a product divisible by 10?