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?
- A. 5
- B. 6
- C. 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
- Problem: How many subsets of {1, ..., 7} contain no two numbers that differ by exactly 1? Run the code. python print(sum(1 for m in…
- Problem: What is the minimum number of moves to sort [4, 1, 3, 2] when one move takes any element to the front? Run the code (answer = n…
- Problem: What is the running time of Ford-Fulkerson when augmenting paths are found by DFS with integer capacities?
- Problem: Which algorithm finds the maximum subarray sum in O(n log n) by splitting the array and handling the crossing case?
- Problem: What does the Pisano period of m describe?
- Problem: Which characterisation of bipartite graphs is correct?