Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture
Problem: A grid has 5 cells in a row, each painted red or blue. How many colourings have no two adjacent cells of the same colour?
- A. 3
- B. 1
- C. 4
- D. 2
Correct answer: D. 2
Alternating colourings are forced once the first cell is chosen, so there are 2 colourings in total.
More Coding Interview Problems questions
- Problem: What is the largest integer n such that n! has at most 3 trailing zeros in base 10?
- Problem: The matrix [[2,0],[0,3]] is raised to the power 4 (matrix power). What is the sum of all entries of the result?
- Problem: A word is "statistics". How many distinct letters appear at least twice in it?
- Problem: A sorted array [2, 3, 5, 7, 11, 13, 17, 19] is searched for 11 using binary search with mid = (lo + hi) // 2 over the inclusive…
- Problem: Consider the string "xyzzyzyx". How many distinct substrings of length 2 are there?
- Problem: The array [1, 4, 6, 3, 8, 2] is processed by a single pass that tracks the maximum so far. How many elements are records…