filmov
tv
LeetCode 344: Reverse String | In-Place Swap in JavaScript

Показать описание
In this video, I solve LeetCode 344: Reverse String using a clean in-place two-pointer approach in JavaScript.
The goal is to reverse the characters of a string in-place, using no extra array or string allocations.
I walk through how to use two pointers (left & right) to swap characters until they meet in the middle. This is a classic pattern used in problems involving arrays and strings.
This solution runs in O(n) time and uses O(1) space, since we only modify the input directly.
What You’ll Learn:
✅ How to reverse a character array without extra space
✅ Why two pointers is the cleanest pattern here
✅ Time & space complexity explained
✅ JavaScript swap logic using a temp variable
Chapters:
0:00 - Problem Breakdown
1:05 - Two-Pointer Strategy Explained
3:45 - JavaScript Code Walkthrough
5:10 - Time & Space Complexity
💬 Want to see a version using destructuring or recursion for fun? Let me know in the comments!
#leetcode #reversestring #javascript #leetcode344 #twopointers #inplacealgorithm #arrayproblems #codinginterview #algorithms #datastructures
The goal is to reverse the characters of a string in-place, using no extra array or string allocations.
I walk through how to use two pointers (left & right) to swap characters until they meet in the middle. This is a classic pattern used in problems involving arrays and strings.
This solution runs in O(n) time and uses O(1) space, since we only modify the input directly.
What You’ll Learn:
✅ How to reverse a character array without extra space
✅ Why two pointers is the cleanest pattern here
✅ Time & space complexity explained
✅ JavaScript swap logic using a temp variable
Chapters:
0:00 - Problem Breakdown
1:05 - Two-Pointer Strategy Explained
3:45 - JavaScript Code Walkthrough
5:10 - Time & Space Complexity
💬 Want to see a version using destructuring or recursion for fun? Let me know in the comments!
#leetcode #reversestring #javascript #leetcode344 #twopointers #inplacealgorithm #arrayproblems #codinginterview #algorithms #datastructures