Reverse String JavaScript Leetcode 344 | Easy Leetcode Question | Two Pointer Solution

preview_player
Показать описание
🔴 Question Link -

✅Connect with me

🔴 Question with Example
Write a function that reverses a string. The input string is given as an array of characters char[].

Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

You may assume all the characters consist of printable ascii characters.

Example 1:

Input: ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]
Рекомендации по теме
Комментарии
Автор

this should be required viewing for CS students aiming for internships I swear

thebluechimera
Автор

Thanks, your videos are always helpful!

One question: Are there any drawbacks to using a for-loop for this solution? E.g. where s[i] would be the left and s[s.length-i] is the right variable, and the for condition is i < (s.length - i)

HeatRisen
Автор

Hello, I am new in algorithm and this so helpful thank you !! Just a question, this won't return anything right ? how can we run our function to return the reverse string ? thank you again

zara.k