Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: The string "abcabcabcabc" is split into consecutive chunks of length 5 from the left (the last chunk may be shorter). How many chunks are there?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
Twelve characters split into chunks of five give two full chunks and one of length two, so three chunks in total.
More Coding Interview Problems questions
- Problem: A binary search tree is built from the values 15, 10, 20, 8, 12, 17, 25 inserted in that order. What is the number of leaves…
- Problem: A stack-based simulation begins with an empty stack. Operations in order: push 4, push 7, push 2, pop, push 9, pop, push 5. What…
- Problem: A tree on 5 nodes is given by edges 1-2, 2-3, 2-4, 4-5. The diameter (in edges) of this tree is what value?
- Problem: A sequence is defined by s(1) = 1, s(2) = 2, and s(n) = s(n−1) + s(n−2) for n ≥ 3. What is the remainder when s(12) is divided by…
- Problem: How many subsets of {1, 2, 3, 4, 5, 6} contain exactly two odd numbers?
- Problem: The product of the first 6 positive odd numbers 1·3·5·7·9·11 is computed. What is that product's value modulo 100?