Skip to content

Commit

Permalink
question/reverse a string
Browse files Browse the repository at this point in the history
-Add new question reverse a string
  • Loading branch information
1-Ujjwal committed Oct 22, 2024
1 parent 069011b commit 61ae4b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Beginner Level πŸ“/Reverse a string/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
You are given a string s.You need to reverse the string.

Examples:

```
Input: s="Geeks"
Outpur: "skeeG"
```

Expected Time Complexity: O(|s|)
Expected Auxiliary Space: O(1)

Constraints:
1<=|s|<=10^4
9 changes: 9 additions & 0 deletions Beginner Level πŸ“/Reverse a string/solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Solution
{
public:
string reverseWord(string str)
{
reverse(str.begin(), str.end());
return str;
}
};

0 comments on commit 61ae4b2

Please sign in to comment.