Back to course home
0% completed
Vote For New Content
Reverse a String (easy)
Problem Statement
Given a string, write a function that uses a stack to reverse the string. The function should return the reversed string.
Examples
Example 1:
Input: "Hello, World!"
Output: "!dlroW ,olleH"
Example 2:
Input: "OpenAI"
Output: "IAnepO"
Example 3:
Input: "Stacks are fun!"
Output: "!nuf era skcatS"
Constraints:
- 1 <= s.length <= 10<sup>5</sup>
s[i]
is a printable ascii character.
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page
Problem Statement
Examples
Try it yourself