Data Structures & AlgorithmsModerateProduct Company SDE · CP practice

Problem: What is the length of the longest common prefix of 'interview', 'internet' and 'interval'? Run the code.

Problem: What is the length of the longest common prefix of 'interview', 'internet' and 'interval'? Run the code.
import os
print(len(os.path.commonprefix(['interview', 'internet', 'interval'])))
What is printed?
  1. A. 5
  2. B. 6
  3. C. 4
  4. D. 7

Correct answer: A. 5

The shared prefix is 'inte', and the third letter after it differs between the words.

More Coding Interview Problems questions

Exams that ask this topic