Leetcode / 344. Reverse String
Pick a programming language:
Here is the source code for the solution to this problem.
class Solution {
public void reverseString(char[] s) {
for (int i = 0; i < s.length / 2; i++) {
char temp = s[i];
s[i] = s[s.length - 1 - i];
s[s.length - 1 - i] = temp;
}
}
}
Did you like the lesson? 😆👍
Consider a donation to support our work: