Data Structures & AlgorithmsHardTCS NQT · Product Company SDE
Problem: How many distinct strings are obtained from "abab" by cyclic rotations (including the rotation by 0)?
- A. 2
- B. 3
- C. 1
- D. 4
Correct answer: A. 2
Distinct rotations are counted as strings, so periodic strings produce repeats. Counting rotation indices gives 4, which overstates the number of distinct strings.
More Coding Interview Problems questions
- Problem: What is the minimum number of character replacements needed to make "abcdba" a palindrome?
- Problem: In how many ways can 100 be made using coins 1, 5, 10, 25 (order does not matter)?
- Problem: How many binary strings of length 5 contain no three consecutive 1s?
- Problem: Stock trading allows unlimited transactions, but after selling you must wait one day before buying (cooldown). Prices are [1, 2…
- Problem: Josephus with step 3: 10 people numbered 1 to 10 stand in a circle. Starting from person 1, count 3 people and eliminate the…
- Problem: The sequence x0 = 1 and x(n+1) = (3·x(n) + 1) mod 7 is generated. The first repeated value appears at some step. What is the…