[Leetcode] (Daily suppression question 344 reversed string)

Insert picture description here

void swap(char *a, char *b) {
    
    
    char t = *a;
    *a = *b, *b = t;
}

void reverseString(char *s, int sSize) {
    
    
    for (int left = 0, right = sSize - 1; left < right; ++left, --right) {
    
    
        swap(s + left, s + right);
    }
}

Guess you like

Origin blog.csdn.net/qq_45657288/article/details/108983229
Recommended