LeetCode Challenge: Reverse String in Java

💻 Day 9/100 – LeetCode Challenge Today I tackled LeetCode 344 – Reverse String (Easy). The task: Reverse a character array in-place, without using extra space. I practiced: ✅ Two-pointer technique ✅ Array manipulation ✅ In-place modifications Java Solution (Two-pointer method): class Solution { public void reverseString(char[] s) { int left = 0, right = s.length - 1; while(left < right){ char temp = s[left]; s[left] = s[right]; s[right] = temp; left++; right--; } } } Example: Input: ['h','e','l','l','o'] → Output: ['o','l','l','e','h'] Takeaways: Two pointers from ends → swap toward the center In-place reversal saves memory (O(1) extra space) Great foundation for problems like rotate array, palindrome checks, and reverse linked lists #100DaysOfCode #LeetCode #Java #CodingChallenge #TwoPointers #Day9

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories