MCPcopy
hub / github.com/azl397985856/leetcode / isCommonPrefix

Function isCommonPrefix

daily/answers/14.longest-common-prefix.js:7–14  ·  view source on GitHub ↗
(strs, middle)

Source from the content-addressed store, hash-verified

5 */
6
7function isCommonPrefix(strs, middle) {
8 const prefix = strs[0].substring(0, middle);
9 for (let i = 1; i < strs.length; i++) {
10 if (!strs[i].startsWith(prefix)) return false;
11 }
12
13 return true;
14}
15/**
16 * @param {string[]} strs
17 * @return {string}

Callers 1

longestCommonPrefixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected