Skip to content

Commit d0b843d

Browse files
Merge pull request #2130 from CodingTestStudy2/최원준
[최원준] 2026/10/05
2 parents a294839 + bdc7bf6 commit d0b843d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def longestCommonPrefix(self, strs: list[str]) -> str:
3+
min_length = min([len(string) for string in strs])
4+
n = len(strs)
5+
6+
ans = ""
7+
for i in range(min_length):
8+
base_char = strs[0][i]
9+
for j in range(1, n):
10+
if strs[j][i] != base_char:
11+
return ans
12+
ans += base_char
13+
return ans

0 commit comments

Comments
 (0)