Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: Count the occurrences of the pattern "aba" in "abababa", where occurrences may overlap.
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
Overlapping matches at every starting index give the count. Scanning non-overlapping blocks misses some occurrences.
More Coding Interview Problems questions
- Problem: The words "listen", "silent", "enlist", "google", "gogole", "cat", "act", "tac", "dog" are grouped by anagram class (words with…
- Problem: In the binary string "1101001110100110", what is the length of the longest contiguous substring containing equal numbers of 0s…
- Problem: For the string "abcab", count the subsequences of length 3 that are palindromes (choose 3 indices i < j < k with s[i] = s[k]; the…
- Problem: What is the minimum number of characters that must be inserted anywhere in "leetcode" to make it a palindrome?
- Problem: What is the length of the longest valid (well-formed) parentheses substring of ")()())(()" ?
- Problem: How many strings of length 8 made of matched parentheses ( and ) are valid (well-formed)?