Skip to content

Commit deb1b82

Browse files
committed
memcpy
1 parent 77b8896 commit deb1b82

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

  • problems/0005-longest-palindromic-substring

problems/0005-longest-palindromic-substring/solution.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ char* longestPalindrome(char* s)
5858
}
5959

6060
char *substring = (char *)malloc((substringLength + 1) * sizeof(char));
61-
int curr = 0;
62-
while (curr < substringLength) {
63-
substring[curr] = s[curr + left];
64-
curr++;
65-
}
61+
memcpy(substring, s + left, substringLength);
6662
substring[substringLength] = '\0';
6763

6864
return substring;

0 commit comments

Comments
 (0)