Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: The string "aaabbcccc" has its runs counted. What is the length of the longest run of identical characters?
- A. 5
- B. 3
- C. 6
- D. 4
Correct answer: D. 4
Runs are maximal blocks of identical consecutive characters; the longest here is the block of four c's. Counting distinct letters would give a different answer.
More Coding Interview Problems questions
- Problem: How many integers from 1 to 300 are divisible by 4 or 6 but not by 12?
- Problem: A list of numbers is [10, 4, 9, 7, 5, 12]. A "peak" is an element strictly greater than both of its neighbours (end elements have…
- Problem: The string "racecarxyz" is examined for palindromic substrings of length at least 5. How many such palindromic substrings are…
- Problem: The number of ways to arrange the letters of "LEVEL" so that the two E's are not adjacent is what value?
- Problem: Consider the sequence 1, 4, 9, 16, … of perfect squares. What is the smallest square that is greater than 500 and also ends in…
- Problem: How many 4-letter strings over {A, B, C} have no letter appearing more than twice?