Skip to content

Commit b41530e

Browse files
Merge pull request #2132 from CodingTestStudy2/정진영
[정진영] 2026/10/05
2 parents 6551285 + a460024 commit b41530e

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param {string[]} strs
3+
* @return {string}
4+
*/
5+
var longestCommonPrefix = function(strs) {
6+
7+
let ans = "";
8+
9+
for (let i = 0; i<strs[0].length; i++){
10+
for(let j = 1; j<strs.length; j++){
11+
if (strs[0][i] !== strs[j][i]) {
12+
return ans;
13+
}
14+
}
15+
16+
ans += strs[0][i];
17+
}
18+
return ans;
19+
};

0 commit comments

Comments
 (0)