2dbi
Home/Oracle/Longest Common Prefix
OOracle·DSASDE-1Technical Phone Screen

Longest Common Prefix

Problem

Find the longest common prefix among an array of strings; empty string if none.

Example

["flower","flow","flight"] -> "fl"

Constraints

  • 1 ≤ n ≤ 200

Approach

Vertical scan or divide-and-conquer; discuss early termination.

added 6 days ago
LeadersAccount