Problem: Just Reverse and String or Array:
You are given a string s. You need to reverse the string.
Example 1:
Input:
s = Geeks
Output: skeeG
Example 2:
Input:
s = for
Output: rof
Your Task:
You only need to complete the function reverseWord() that takes s as parameter and returns the reversed string.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).
Constraints:
1 <= |s| <= 10000
Geeks For Geeks Question- Reverse a String
We are Going to solve this problem using python
Solution -
class Solution:
def reverseWord(self, str: str) -> str:
#your code
str_list = list(str)
reverse_str = "" .join(str_list[::-1])
return reverse_str
Follow for More Solution.....
Put Your Thought or Query Here