Data Structures & AlgorithmsHardICPC regional · Product Company SDE
Problem: The string "mississippi" contains repeated substrings. What is the length of the longest substring that appears at least twice (occurrences may overlap)?
- A. 5
- B. 3
- C. 6
- D. 4
Correct answer: D. 4
Test every length from the largest down: 'issi' appears at positions 1 and 4, so length 4 repeats, and no longer substring does. Checking only single letters underestimates the answer.
More Coding Interview Problems questions
- Problem: For the string "abcabcdab", how many substrings of length 3 occur exactly once?
- Problem: How many integers from 1 to 500 are NOT perfect squares and NOT perfect cubes?
- Problem: The dynamic array doubles its capacity whenever it is full, starting from capacity 1. After inserting 9 elements one by one, how…
- Problem: In a binary heap stored in an array with 1-based indexing, the array [1, 3, 2, 7, 4, 5, 6] is a valid min-heap. What is the sum…
- Problem: Vertices 0–5 form a graph with edges 0-1, 1-2, 2-3, 3-0 and 4-5. A BFS from vertex 0 gives each vertex a distance. What is the…
- Problem: A stack-sortable check is applied to the permutation [3, 1, 2]: elements are pushed in order and popped whenever the top equals…