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 @@ -253,22 +253,18 @@ end
253
253
254
254
#### C
255
255
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
+ }
267
265
}
268
- }
269
- return strs[ 0] ;
266
+ return strs[ 0] ;
270
267
}
271
-
272
268
```
273
269
274
270
<!-- tabs:end -->
You can’t perform that action at this time.
0 commit comments