Skip to content

Commit 12ce950

Browse files
authored
Update README.md
1 parent a28b9fd commit 12ce950

File tree

1 file changed

+10
-14
lines changed
  • solution/0000-0099/0014.Longest Common Prefix

1 file changed

+10
-14
lines changed

solution/0000-0099/0014.Longest Common Prefix/README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -253,22 +253,18 @@ end
253253

254254
#### C
255255

256-
```C
257-
258-
char *longestCommonPrefix(char **strs, int strsSize) {
259-
if (strsSize == 0)
260-
return "";
261-
for (int i = 0; strs[0][i]; i++) {
262-
for (int j = 1; j < strsSize; j++) {
263-
if (strs[j][i] != strs[0][i]) {
264-
strs[0][i] = '\0';
265-
return strs[0];
266-
}
256+
```c
257+
char* longestCommonPrefix(char** strs, int strsSize) {
258+
for (int i = 0; strs[0][i]; i++) {
259+
for (int j = 1; j < strsSize; j++) {
260+
if (strs[j][i] != strs[0][i]) {
261+
strs[0][i] = '\0';
262+
return strs[0];
263+
}
264+
}
267265
}
268-
}
269-
return strs[0];
266+
return strs[0];
270267
}
271-
272268
```
273269
274270
<!-- tabs:end -->

0 commit comments

Comments
 (0)