LeetCode 344. Reverse String Posted on 2021-09-06 In Leetcode , String Symbols count in article: 368 Reading time ≈ 1 mins. QuestionWrite a function that reverses a string. The input string is given as an array of characters s. https://leetcode.com/problems/reverse-string/ Solution1 12345678910111213class Solution { public void reverseString(char[] s) { int i = 0, j = s.length - 1; while (i < j){ char tmp = s[i]; s[i] = s[j]; s[j] = tmp; i++; j--; } return; }} Complexity: Time complexity: O(n) Space complexity: O(1) Post author: MrainW Post link: https://mrainw.github.io/2021/09/06/LeetCode 344. Reverse String/ Copyright Notice: All articles in this blog are licensed under BY-NC-SA unless stating additionally. Welcome to my other publishing channels WeChat