Skip to content

Commit f3d22d6

Browse files
add javascript solution for 014
1 parent 3a67ad4 commit f3d22d6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const longestCommonPrefix = function(strs){
2+
if(strs.length === 0) return '';
3+
for(let j = 0; j < strs[0].length; j++){
4+
for(let i = 0; i < strs.length; i++){
5+
if(strs[0][j] !== strs[i][j]){
6+
return strs[0].substring(0,j);
7+
}
8+
}
9+
}
10+
return strs[0];
11+
}

0 commit comments

Comments
 (0)