File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
solution/0000-0099/0014.Longest Common Prefix Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -252,22 +252,18 @@ end
252
252
253
253
#### C
254
254
255
- ``` C
256
-
257
- char *longestCommonPrefix (char ** strs, int strsSize) {
258
- if (strsSize == 0)
259
- return "";
260
- for (int i = 0; strs[ 0] [ i ] ; i++) {
261
- for (int j = 1; j < strsSize; j++) {
262
- if (strs[ j] [ i ] != strs[ 0] [ i ] ) {
263
- strs[ 0] [ i ] = '\0';
264
- return strs[ 0] ;
265
- }
255
+ ``` c
256
+ char * longestCommonPrefix (char** strs, int strsSize) {
257
+ for (int i = 0; strs[ 0] [ i ] ; i++) {
258
+ for (int j = 1; j < strsSize; j++) {
259
+ if (strs[ j] [ i ] != strs[ 0] [ i ] ) {
260
+ strs[ 0] [ i ] = '\0';
261
+ return strs[ 0] ;
262
+ }
263
+ }
266
264
}
267
- }
268
- return strs[ 0] ;
265
+ return strs[ 0] ;
269
266
}
270
-
271
267
```
272
268
273
269
<!-- tabs:end -->
You can’t perform that action at this time.
0 commit comments