Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 1.44 KB

File metadata and controls

19 lines (12 loc) · 1.44 KB

Longest Common Prefix medium

by Tom Cleary @thomcleary

Take the Challenge

Longest Common Prefix

Write a type, LongestCommonPrefix that returns the longest common prefix string amongst a tuple of strings.

If there is no common prefix, return an empty string "".

type Common = LongestCommonPrefix<["flower", "flow", "flight"]>
//   ?^ "fl"

type Uncommon = LongestCommonPrefix<["dog", "racecar", "race"]>
//   ?^ ""

Inspired by LeetCode 14. Longest Common Prefix


Back Share your Solutions Check out Solutions