deno.land / x / masx200_leetcode_test@10.6.5 / longest-common-prefix / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export default function longestCommonPrefix(strs: string[]): string { let ret = ""; const len = Math.min(...strs.map((s) => s.length)); for (let i = 0; i < len; i++) { for (const s of strs) { if (s[i] !== strs[0][i]) { return ret; } } ret += strs[0][i]; } return ret;}
masx200_leetcode_test

Version Info

Tagged at
a year ago