Data Structures & AlgorithmsHardTCS NQT · Infosys
How many distinct strings can be obtained from abc by swapping two adjacent characters at most once (including the original string)?
- A. 4
- B. 3
- C. {C-1}
- D. 5
Correct answer: B. 3
The original abc plus the strings bac and acb from the two adjacent swaps make 3 distinct results.
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 passenger count changes by +3, -1, +2, -2, +4, -3 at successive stops, starting from 0. What is the maximum number of passengers on…
- How many integers x in [1, 500] have digit sum equal to 10?
- How many unordered pairs {a, b} with a < b and 1 <= a, b <= 30 have a b a perfect square?
- An array is [1, 2, 1, 2, 1, 2] (indices 0 to 5). How many pairs of even-indexed positions i < j hold equal values?
- What is the sum of all proper divisors of 220 (divisors less than 220)?
- How many integers in [1, 100] have an odd number of positive divisors?